4
剛剛更新我的swiftmailer結帳到最新版本4.3.0。下面非常簡單的代碼不再起作用,並且連接超時:swiftmailer完全破解爲smtp?
<?
require_once 'Swift-4.3.0/lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('email-smtp.us-east-1.amazonaws.com',465, 'tls')
->setUsername('USERNAME')
->setPassword('PASSWORD')
;
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Yo')
->setFrom(array('[email protected]' => 'Josh'))
->setTo(array('[email protected]'))
->setBody('Here is the message itself')
;
$result = $mailer->send($message);
然後我得到如下:
PHP Fatal error: Uncaught exception 'Swift_IoException' with message 'Connection to tcp://email-smtp.us-east-1.amazonaws.com:465 Timed Out' in /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Transport/StreamBuffer.php:169
Stack trace:
#0 /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Transport/AbstractSmtpTransport.php(400): Swift_Transport_StreamBuffer->readLine(0)
#1 /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Transport/AbstractSmtpTransport.php(291): Swift_Transport_AbstractSmtpTransport->_getFullResponse(0)
#2 /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Transport/AbstractSmtpTransport.php(119): Swift_Transport_AbstractSmtpTransport->_readGreeting()
#3 /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start()
#4 /home/jnankin/Desktop/email.php(17): Swift_Mailer->send(Object(Swift_Message))
#5 {main}
thrown in /home/jnankin/Desktop/Swift-4.3.0/lib/classes/Swift/Transport/StreamBuffer.php on line 169
UPDATE:此完全相同的代碼(不用任何改動)工程在版本4.1.2中。版本4.1.3不再有效。我嘗試過不同的SMTP服務器:mailgun,sendgrid等...這似乎swiftmailer特定。
您是否嘗試過使用其他服務器? – jeroen 2013-02-26 16:08:12
是的,請參閱更新 – 2013-02-26 16:14:08