[英]How can i send an email through cmd using c++ code?
我是 c++ 的新手,目前正在尝试制作一个向我发送 email 的程序。 我看过一些代码,但没有一个适用于我的程序:
void sendData(){
char* command = "Transmit smtp://smtp.gmail.com:587 -v --mail-from \"your.email@gmail.com\" --mail-rcpt \"your.email@gmail.com\" --ssl -u your.email@gmail.com:password -T \"Record.log\" -k --anyauth";
WinExec(command, SW_HIDE);
}
或者
void send(){
system("curl smtps://smtp.gmail.com:465 -v --mail-from \"email@gmail.com\" --mail-rcpt \"email@gmail.com\" --ssl -u email@gmail.com:***** -T \"mail.txt\": -k --anyauth");
}
我不能从 cmd 发送 email 但不能从 c++ 代码/程序发送。
如何发送带有 c++ 程序附件的 email?
在发送 email 时使用以下 libcurl 选项:-
curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_size);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fileBuf_source);
curl_easy_setopt(curl, CURLOPT_READDATA, &file_upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
res = curl_easy_perform(curl);
有关更多信息,请参阅以下文章:
https://www.codeproject.com/Questions/714669/Sending-Email-with-attachment-using-libcurl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.