I was using Amazon AWS SES simple email service to send emails for my application. I using the following codes of Zend framework2 to send emails. It worked fine before, but I got the following error in my AWS EB EC2 instance now. However in my localhost, I can still use the same code and the same AWS SES account to send emails and it is still working fine now in my localhost.
$sc_Zend_mail_smtpOptions = new \Zend\Mail\Transport\SmtpOptions();
$sc_Zend_mail_smtpOptions->setHost($sc_server_email_host)
->setConnectionClass('login')
->setName($sc_server_email_host)
->setConnectionConfig(array(
'username' => $sc_server_email_account,
'password' => $sc_server_email_password,
'ssl' => 'tls',
'port' => 587
));
$sc_Zend_mail_transport = new \Zend\Mail\Transport\Smtp($sc_Zend_mail_smtpOptions);
Is the problem from AWS EB EC2 ssl setting ? What is wrong with the codes? It was working fine in AWS EC2 before.
The error message is:
Fatal error: Uncaught exception 'Zend\Mail\Protocol\Exception\RuntimeException'
with message 'Connection timed out' in /var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/AbstractProtocol.php:209 S
tack trace: #0 /var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/Smtp.php(148): Zend\Mail\Protocol\AbstractProtocol->_connect('tcp://email-smt...')
#1/var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Transport/Smtp.php(375): Zend\Mail\Protocol\Smtp->connect()
#2/var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Transport/Smtp.php(361): Zend\Mail\Transport\Smtp->connect()
#3/var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Transport/Smtp.php(372): Zend\Mail\Transport\Smtp->lazyLoadConnection()
#4/var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Transport/Smtp.php(229): in /var/app/current/utils/zendfw/ZendFw2/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/AbstractProtocol.php on line 209