Question:Im trying to send an email using curl c++, i managed to log in well and when i run the program it works fine, does not throw any error, but the email never comes.
This is my code:
const char *data = payload_text;is the data pointer, right?
then READFUNCTION takes as an argument a function which return the size of the data and i think that is what
size_t read_function(char *buffer, size_t size, size_t nmemb,char *data)is doing.
I am new in this so any advice would be good for me.
Answer:I found this to be a helpful starting point: https://curl.se/libcurl/c/smtp-mail.html
There are two main problems with your code:
read_functiondidn’t keep track of how much of the payload has been read so it would keep giving the same content to libcurl over and over and never signal the end of the message.
- You were setting CURLOPT_MAIL_RCPT to a string when in fact it should be a
struct curl_slist *because there can be multiple recipients.
Here is a fixed example that I tested on my computer and it worked. Private data at the top of the file was modified before posting.
If you have better answer, please add a comment about this, thank you!