I am using poco library to send a email

first I installed the libraries on my ubuntu

sudo apt-get install libpoco-dev     


using namespace Poco::Net;

int main (int argc, char **argv)
    MailMessage msg;
    msg.addRecipient (MailRecipient (MailRecipient::PRIMARY_RECIPIENT,

    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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.