I am new to c++, currently trying to make a program that sends me email. I have seen a couple of codes but none worked on my program:
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);
}
or
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");
}
I cant send an email from cmd but not from a c++ code/program.
How can i send an email with attachment from c++ program?
Use below libcurl options while sending email:-
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);
For more information refer below articles:
https://www.codeproject.com/Questions/714669/Sending-Email-with-attachment-using-libcurl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.