title: Poco unable to send email
body: <p>I am trying to use the Poco library to send an email. Platform is <strong>OS X</strong>, <strong>Yosemite 10.10.2</strong> I am using <strong>Qt 5.3 32 bit</strong>. I followed the official instructions from <a href="http://pocoproject.org/docs/00200-GettingStarted.html" rel="nofollow">here</a>, and since I am using 32 bit Qt, and want the libraries to be statically linked, I used </p>
  
  <p><code>./configure --omit=Data/ODBC,Data/MySQL --config=Darwin32</code></p>
  
  <p>(I don't require the <code>MySQL</code>/<code>ODBC</code> modules). And it installed in <code>/usr/local</code> correctly, following which I linked the necessary dynamic  libraries (<code>PocoNet</code> and <code>PocoFoundation</code> and 10 other libraries), and tried this following code, which I found <a href="http://rosettacode.org/wiki/Send_email#C.2B.2B" rel="nofollow">here</a>. What I am trying to do is send an email to my gmail account from my account itself:</p>
  
  <pre><code>#include "MailSender.hpp"
  
  #include &lt;Poco/Net/MailMessage.h&gt;
  #include &lt;Poco/Net/MailRecipient.h&gt;
  #include &lt;Poco/Net/SMTPClientSession.h&gt;
  #include &lt;Poco/Net/NetException.h&gt;
  #include &lt;Poco/Net/SecureSMTPClientSession.h&gt;
  #include &lt;Poco/Net/InvalidCertificateHandler.h&gt;
  #include &lt;Poco/Net/AcceptCertificateHandler.h&gt;
  #include &lt;Poco/Net/SSLManager.h&gt;
  #include &lt;Poco/Net/SecureStreamSocket.h&gt;
  #include &lt;Poco/Net/MailRecipient.h&gt;
  
  #include &lt;iostream&gt;
  #include &lt;QDebug&gt;
  
  using Poco::Net::InvalidCertificateHandler;
  using Poco::Net::AcceptCertificateHandler;
  using Poco::Net::Context;
  using Poco::Net::SSLManager;
  using Poco::Net::SecureStreamSocket;
  using Poco::Net::SocketAddress;
  using Poco::Net::SecureSMTPClientSession;
  using Poco::Net::SMTPClientSession;
  using Poco::SharedPtr;
  using Poco::Net::MailMessage;
  using Poco::Net::MailRecipient;
  using namespace std;
  
  MailSender::MailSender()
  {
  SharedPtr&lt;InvalidCertificateHandler&gt; pCert = new AcceptCertificateHandler(false);
  
  string host = "smtp.gmail.com";
  int port = 25;
  
  Context::Ptr pContext = new Poco::Net::Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_NONE, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
  SSLManager::instance().initializeClient(0, pCert, pContext);
  
  Poco::Net::SecureSMTPClientSession* pSecure = new Poco::Net::SecureSMTPClientSession(host, port);
  Poco::Net::SecureSMTPClientSession* pSession_ = new Poco::Net::SecureSMTPClientSession(host, port);
  
  SecureStreamSocket* pSSLSocket = new SecureStreamSocket(pContext);
  pSSLSocket-&gt;connect(SocketAddress(host, port));
  pSecure = new SecureSMTPClientSession(*pSSLSocket);
  pSession_ = pSecure;
  pSecure-&gt;login();
  if (!pSecure-&gt;startTLS(pContext))
     throw std::string("Failed to start TLS connection.");
  
  std::string sUserName = "my_email_id";
  std::string sPassword = "my_password";
  
  pSession_-&gt;login(SMTPClientSession::AUTH_LOGIN, sUserName, sPassword);
  
  
  string to = "my_email_id";
  string from = "my_email_id";
  string subject = "Your first e-mail message sent using Poco Libraries";
  subject = MailMessage::encodeWord(subject, "UTF-8");
  string content = "Well done! You've successfully sent your first message using Poco SMTPClientSession";
  MailMessage message;
  message.setSender(from);
  message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, to));
  message.setSubject(subject);
  message.setContentType("text/plain; charset=UTF-8");
  message.setContent(content, MailMessage::ENCODING_8BIT);
  
  
  
  try {
      pSession_-&gt;sendMessage(message);
      pSession_-&gt;close();
  } catch (Poco::Net::SMTPException &amp;e) {
      qDebug() &lt;&lt; e.displayText().c_str() &lt;&lt; endl;
  }
  catch (Poco::Net::NetException &amp;e) {
      qDebug() &lt;&lt; e.displayText().c_str() &lt;&lt; endl;
  }
  
  }
  </code></pre>
  
  <p>When I run this, I get the following error:</p>
  
  <p><strong>libc++abi.dylib: terminating with uncaught exception of type Poco::Net::SSLException: SSL Exception</strong> in the Qt console.</p>
  
  <p>The Apple generated crash dump shows this:</p>
  
  <pre><code>Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
  0   libsystem_kernel.dylib          0x9b7f369a __pthread_kill + 10
  1   libsystem_pthread.dylib         0x90a04f19 pthread_kill + 101
  2   libsystem_c.dylib               0x96861eee abort + 156
  3   libc++abi.dylib                 0x965782f9 abort_message + 169
  4   libc++abi.dylib                 0x9659b483 default_terminate_handler() + 272
  5   libc++abi.dylib                 0x96598ac0 std::__terminate(void (*)()) + 14
  6   libc++abi.dylib                 0x965986ee __cxa_rethrow + 103
  7   libPocoNetSSL.30.dylib          0x02c253ff Poco::Net::SecureSocketImpl::connectSSL(bool) + 943
  8   libPocoNetSSL.30.dylib          0x02c24fee Poco::Net::SecureSocketImpl::connect(Poco::Net::SocketAddress const&amp;, bool) + 94
  9   libPocoNetSSL.30.dylib          0x02c28a61 Poco::Net::SecureStreamSocketImpl::connect(Poco::Net::SocketAddress const&amp;) + 49
  10  libPocoNet.30.dylib             0x02b1368b Poco::Net::StreamSocket::connect(Poco::Net::SocketAddress const&amp;) + 27
  </code></pre>
  
  <p>Somehow, the code fails at <code>pSSLSocket-&gt;connect(SocketAddress(host, port));</code></p>
  
  <p>I have linked <code>PocoNet</code>, <code>PocoNetSSL</code>, <code>PocoFoundation</code>, etc., in all, all 12 dynamic libraries generated.</p>
  
  <p>Any idea how I fix this?</p>