I am using poco library to send a email
first I installed the libraries on my ubuntu
sudo apt-get install libpoco-dev
code
using namespace Poco::Net;
int main (int argc, char **argv)
{
try
{
MailMessage msg;
msg.addRecipient (MailRecipient (MailRecipient::PRIMARY_RECIPIENT,
"john@gmail.com",
"John"));
msg.setSender ("Anthony Smiths <anthonysmiths5456@gmail.com>");
msg.setSubject ("sending a email using POCO library");
msg.setContent ("Hi, this is a test email");
SMTPClientSession smtp ("smtp.gmail.com");
smtp.login ();
smtp.sendMessage (msg);
smtp.close ();
std::cerr << "Sent mail successfully!" << std::endl;
}
catch (std::exception &e)
{
std::cerr << "failed to send mail: " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
However after I compile and do ./a.out, it display this error
fail to send email: SMTP Exception.
Please help