I recently wrote an application on windows using the Poco library. I'm porting it over to OSX and Linux at the moment.
I'm having trouble getting some code to run on OSX for sending e-mails.
- Code: Select all
int sendEmail_message (string inputTo, string inputSubject, string inputMessage)
{
SSLInitializer sslInitializer;
string mailhost = "smtp.gmail.com";
string sender = "email@gmail.com";
string recipient = inputTo;
try
{
SharedPtr<InvalidCertificateHandler> pCert = new AcceptCertificateHandler(false);
Context::Ptr pContext = new Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_NONE, 9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
SSLManager::instance().initializeClient(0, pCert, pContext);
MailMessage message;
message.setSender(sender);
message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, recipient));
message.setSubject(inputSubject);
std::string content;
content += inputMessage;
message.addContent(new StringPartSource(content));
SecureSMTPClientSession session(mailhost);
session.login();
session.startTLS(pContext);
session.login(SMTPClientSession::AUTH_LOGIN, "email@gmail.com", "password");
session.sendMessage(message);
session.close();
return 0;
}
catch (Exception& exc)
{
cerr << padding << exc.displayText() << endl;
return 1;
}
}
The code above runs fine on windows and sends e-mails. But if I attempt to run it on OSX, It hangs for a while and then writes out "timeout".
Everything is building ok on OSX, it just times out at run time. As far as I can tell, it's hanging on the line:
- Code: Select all
SecureSMTPClientSession session(mailhost);
Is there anything anyone can suggest to help me track down what the problem is? It would be ok if I had some more information as to what is happening or a way to output a log of the connection. I'm pretty new to OSX development, so I might be missing something obvious.
-Matt





