{"action":"created","issue":{"url":"https://api.github.com/repos/pocoproject/poco/issues/768","labels_url":"https://api.github.com/repos/pocoproject/poco/issues/768/labels{/name}","comments_url":"https://api.github.com/repos/pocoproject/poco/issues/768/comments","events_url":"https://api.github.com/repos/pocoproject/poco/issues/768/events","html_url":"https://github.com/pocoproject/poco/issues/768","id":66017740,"number":768,"title":"Unable to send email with Poco","user":{"login":"Cupidvogel","id":7725182,"avatar_url":"https://avatars.githubusercontent.com/u/7725182?v=3","gravatar_id":"","url":"https://api.github.com/users/Cupidvogel","html_url":"https://github.com/Cupidvogel","followers_url":"https://api.github.com/users/Cupidvogel/followers","following_url":"https://api.github.com/users/Cupidvogel/following{/other_user}","gists_url":"https://api.github.com/users/Cupidvogel/gists{/gist_id}","starred_url":"https://api.github.com/users/Cupidvogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cupidvogel/subscriptions","organizations_url":"https://api.github.com/users/Cupidvogel/orgs","repos_url":"https://api.github.com/users/Cupidvogel/repos","events_url":"https://api.github.com/users/Cupidvogel/events{/privacy}","received_events_url":"https://api.github.com/users/Cupidvogel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pocoproject/poco/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-04-02T21:46:43Z","updated_at":"2015-04-03T16:46:12Z","closed_at":null,"body":"I am trying to use Poco to send an email. I have linked the following dynamic libraries -\r\n\r\nCppUnit.1.dylib, PocoCrypto.30.dylib, PocoData.30.dylib, PocoDataSQLite.30.dylib, PocoFoundation.30.dylib, PocoJSON.30.dylib, PocoMongoDB.30.dylib, PocoNet.30.dylib, PocoNetSSL.30.dylib, PocoUtil.30.dylib, PocoXML.30.dylib, PocoZip.30.dylib.\r\n\r\nI need to use 32 bit version of it, so I ran \r\n```\r\n./configure --omit=Data/ODBC,Data/MySQL --config=Darwin32\r\n```\r\nThis is my code:\r\n```\r\n#include \"MailSender.hpp\"\r\n\r\n#include \"Poco/Net/MailMessage.h\"\r\n#include \"Poco/Net/MailRecipient.h\"\r\n#include \"Poco/Net/SMTPClientSession.h\"\r\n#include \"Poco/Net/NetException.h\"\r\n#include \"Poco/Net/SecureSMTPClientSession.h\"\r\n#include \"Poco/Net/InvalidCertificateHandler.h\"\r\n#include \"Poco/Net/AcceptCertificateHandler.h\"\r\n#include \"Poco/Net/SSLManager.h\"\r\n#include \"Poco/Net/SecureStreamSocket.h\"\r\n#include \"Poco/Net/MailRecipient.h\"\r\n\r\nusing Poco::Net::InvalidCertificateHandler;\r\nusing Poco::Net::AcceptCertificateHandler;\r\nusing Poco::Net::Context;\r\nusing Poco::Net::SSLManager;\r\nusing Poco::Net::SecureStreamSocket;\r\nusing Poco::Net::SocketAddress;\r\nusing Poco::Net::SecureSMTPClientSession;\r\nusing Poco::Net::SMTPClientSession;\r\nusing Poco::SharedPtr;\r\nusing Poco::Net::MailMessage;\r\nusing Poco::Net::MailRecipient;\r\nusing namespace std;\r\n\r\nMailSender::MailSender()\r\n{\r\nSharedPtr<InvalidCertificateHandler> pCert = new AcceptCertificateHandler(false);\r\n\r\nstring host = \"smtp.gmail.com\";\r\nint port = 25;\r\n\r\nContext::Ptr pContext = new Poco::Net::Context(Context::CLIENT_USE, \"\", \"\", \"\", Context::VERIFY_NONE, 9, false, \"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH\");\r\nSSLManager::instance().initializeClient(0, pCert, pContext);\r\n\r\nPoco::Net::SecureSMTPClientSession* pSecure = new Poco::Net::SecureSMTPClientSession(host, port);\r\nPoco::Net::SecureSMTPClientSession* pSession_ = new Poco::Net::SecureSMTPClientSession(host, port);\r\n\r\nSecureStreamSocket* pSSLSocket = new SecureStreamSocket(pContext);\r\npSSLSocket->connect(SocketAddress(host, port));\r\npSecure = new SecureSMTPClientSession(*pSSLSocket);\r\npSession_ = pSecure;\r\npSecure->login();\r\nif (!pSecure->startTLS(pContext))\r\n   throw std::string(\"Failed to start TLS connection.\");\r\n\r\nstd::string sUserName = \"my_email_id\";\r\nstd::string sPassword = \"my_password\";\r\n\r\npSession_->login(SMTPClientSession::AUTH_LOGIN, sUserName, sPassword);\r\n\r\n\r\nstring to = \"my_email_id\";\r\nstring from = \"my_email_id\";\r\nstring subject = \"Your first e-mail message sent using Poco Libraries\";\r\nsubject = MailMessage::encodeWord(subject, \"UTF-8\");\r\nstring content = \"Well done! You've successfully sent your first message using Poco SMTPClientSession\";\r\nMailMessage message;\r\nmessage.setSender(from);\r\nmessage.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, to));\r\nmessage.setSubject(subject);\r\nmessage.setContentType(\"text/plain; charset=UTF-8\");\r\nmessage.setContent(content, MailMessage::ENCODING_8BIT);\r\n\r\n\r\n\r\ntry {\r\n    pSession_->sendMessage(message);\r\n    pSession_->close();\r\n} catch (Poco::Net::SMTPException &e) {\r\n    qDebug() << e.displayText().c_str() << endl;\r\n}\r\ncatch (Poco::Net::NetException &e) {\r\n    qDebug() << e.displayText().c_str() << endl;\r\n}\r\n\r\n}\r\n```\r\nWhen I run this, my app crashes at runtime, with the following error message on Qt console:\r\n\r\n```\r\nlibc++abi.dylib: terminating with uncaught exception of type Poco::Net::SSLException: SSL Exception\r\n\r\n```\r\nThe system generated Apple crash report shows something like this:\r\n```\r\nThread 0 Crashed:: Dispatch queue: com.apple.main-thread\r\n0   libsystem_kernel.dylib        \t0x9b7f369a __pthread_kill + 10\r\n1   libsystem_pthread.dylib       \t0x90a04f19 pthread_kill + 101\r\n2   libsystem_c.dylib             \t0x96861eee abort + 156\r\n3   libc++abi.dylib               \t0x965782f9 abort_message + 169\r\n4   libc++abi.dylib               \t0x9659b483 default_terminate_handler() + 272\r\n5   libc++abi.dylib               \t0x96598ac0 std::__terminate(void (*)()) + 14\r\n6   libc++abi.dylib               \t0x965986ee __cxa_rethrow + 103\r\n7   libPocoNetSSL.30.dylib        \t0x02c253ff Poco::Net::SecureSocketImpl::connectSSL(bool) + 943\r\n8   libPocoNetSSL.30.dylib        \t0x02c24fee Poco::Net::SecureSocketImpl::connect(Poco::Net::SocketAddress const&, bool) + 94\r\n9   libPocoNetSSL.30.dylib        \t0x02c28a61 Poco::Net::SecureStreamSocketImpl::connect(Poco::Net::SocketAddress const&) + 49\r\n10  libPocoNet.30.dylib           \t0x02b1368b Poco::Net::StreamSocket::connect(Poco::Net::SocketAddress const&) + 27\r\n```\r\nThe code fails at \"pSSLSocket->connect(SocketAddress(host, port));\" part.\r\n\r\nHow do I fix this? Platform - OS X Yosemite 10.10.2, Qt 5.3.1 32 bit."},"comment":{"url":"https://api.github.com/repos/pocoproject/poco/issues/comments/89349385","html_url":"https://github.com/pocoproject/poco/issues/768#issuecomment-89349385","issue_url":"https://api.github.com/repos/pocoproject/poco/issues/768","id":89349385,"user":{"login":"bakercp","id":300484,"avatar_url":"https://avatars.githubusercontent.com/u/300484?v=3","gravatar_id":"","url":"https://api.github.com/users/bakercp","html_url":"https://github.com/bakercp","followers_url":"https://api.github.com/users/bakercp/followers","following_url":"https://api.github.com/users/bakercp/following{/other_user}","gists_url":"https://api.github.com/users/bakercp/gists{/gist_id}","starred_url":"https://api.github.com/users/bakercp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakercp/subscriptions","organizations_url":"https://api.github.com/users/bakercp/orgs","repos_url":"https://api.github.com/users/bakercp/repos","events_url":"https://api.github.com/users/bakercp/events{/privacy}","received_events_url":"https://api.github.com/users/bakercp/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T16:46:12Z","updated_at":"2015-04-03T16:46:12Z","body":"https://github.com/pocoproject/poco/blob/develop/NetSSL_OpenSSL/samples/Mail/src/Mail.cpp#L104\r\n\r\nChange this to:\r\n\r\n```\r\nSecureSMTPClientSession session(mailhost, 465); // by default it uses port 25 from the SMTPClientSession enum\r\n```\r\n\r\nSee also http://pocoproject.org/docs/Poco.Net.SecureSMTPClientSession.html.\r\n\r\nI'd recommend that the default value for the port in SecureSMTPClientSession should be changed from `SMTPClientSession::SMTP_PORT` to a new default value for ssmtp. "}}