簡體   English   中英

AWS SES 簡單 email 服務,Zend 超時錯誤 email

[英]AWS SES simple email service, time out error with Zend email

我使用 Amazon AWS SES simple email 服務為我的應用程序發送電子郵件。 我使用 Zend framework2 的以下代碼發送電子郵件。 之前它運行良好,但現在我的 AWS EB EC2 實例中出現以下錯誤。 但是,在我的本地主機中,我仍然可以使用相同的代碼和相同的 AWS SES 帳戶發送電子郵件,並且它現在在我的本地主機中仍然可以正常工作。

$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);

AWS EB EC2 ssl 設置的問題嗎? 這些代碼有什么問題? 它之前在 AWS EC2 中運行良好。

錯誤信息是:

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

似乎 AWS EC2 中的服務器實例不再允許設置舊端口。 將端口設置移到 setConnectionConfig 數組之外確實使其在 AWS EB EC2 以及本地主機中再次工作。

$sc_Zend_mail_smtpOptions->setHost($sc_server_email_host)
            ->setConnectionClass('login')
            ->setName($sc_server_email_host)
            ->setPort(587)
            ->setConnectionConfig(array(
                'username' => $sc_server_email_account,
                'password' => $sc_server_email_password,
                'ssl' => 'tls'
            ));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM