Is Swiftmailer completely broken for smtp?

Just updated my swiftmailer check to the latest version 4.3.0. The following VERY simple code no longer works, and connection time:

<? 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(' jnankin@gmail.com ' => 'Josh')) ->setTo(array(' jnankin@gmail.com ')) ->setBody('Here is the message itself') ; $result = $mailer->send($message); 

Then I get the following:

 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: This exact code (without any changes) works in version 4.1.2. Version 4.1.3 this no longer works. I tried different SMTP servers: mailgun, sendgrid, etc .... this seems to be specific to swiftmailer.

+4
source share
1 answer

It looks like starting from version 4.1.3 swiftmailer added support for starttls. In version 4.1.2 and eariler, using port 465 and specifying 'tls', how the encryption method worked fine. However, 4.1.3 looks like it does not support the use of the tls wrapper and allows launch. In other words, tls stopped the meaning of tls wrapper and began to understand starttls. Thus, changing the port to 587 instead of 465 (as indicated in the SES documentation, should be used for starttls connections) solved the problem for me.

Very bad move by swiftmailer imho.

+13
source

All Articles