2

I try to send an e-mail with Swiftmailer. But it doesn't work... This is what I tried:

$transport = Swift_SmtpTransport::newInstance('smtp.life.com', 25)
->setUsername('olivier-zwat@hotmail.be')
->setPassword('the correct pasword');

I can't find the solution for solving this problem... *BTW I'm a Dutchman! ;-)

  • what errors do you get? "doesn't work" is not a good description. – cweiske Feb 07 '13 at 09:10
  • The errors I get see here: http://oli4tje.3owl.com/PEAR/Swiftmailer/test.php – Olivier Peeters Mar 08 '13 at 10:34
  • "Service Temporarily Unavailable" is not helpful. – cweiske Mar 08 '13 at 12:08
  • Sorry, my server is doing some things I don't understand... So the error starts with: "Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first "' in /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386 Stack trace: #0 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): "... – Olivier Peeters Mar 08 '13 at 17:17
  • And goes on with .."Swift_Transport_AbstractSmtpTransport->_assertResponseCode('530 5.7.0 Must ...', Array) #1 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(245): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM: – Olivier Peeters Mar 08 '13 at 17:18
  • Last part: .."Swift_Transport_EsmtpTransport->executeCommand('MAIL FROM: _doMailFromCommand('olivi in /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 386" – Olivier Peeters Mar 08 '13 at 17:18

3 Answers3

1

530 5.7.0 Must issue a STARTTLS command first

You need to configure SwiftMailer to use a SSL connection via STARTTLS. It is supported since version 4.1.3.

cweiske
  • 30,033
  • 14
  • 133
  • 194
  • So I tryed: "$transport = Swift_SmtpTransport::newInstance('smtp.live.com', 587, 'starttls')" instead of "$transport = Swift_SmtpTransport::newInstance('smtp.live.com', 587)" But now I got another error => "Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "", with message ""' in /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386 Stack trace: #0 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): ".. – Olivier Peeters Mar 09 '13 at 12:39
  • .."Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array) #1 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(245): Swift_Transport_AbstractSmtpTransport->executeCommand('RSET??', Array, Array) #2 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php(47): Swift_Transport_EsmtpTransport->executeCommand('RSET??', Array) #3 /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php(179): ".. – Olivier Peeters Mar 09 '13 at 12:40
  • .."Swift_Transport_Esmtp_Auth_PlainAuthenticator->authenticate(Object(Swift_SmtpTransport), 'peeterskenolivi...', 'oli4is1ole') #4 /home/u3997 in /home/u399707880/public_html/PEAR/Swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 386" – Olivier Peeters Mar 09 '13 at 13:03
0

I think you should change 'smtp.life.com' to 'smtp.live.com'.

vjnrv
  • 91
  • 1
  • 2
  • So I changed it in this => $transport = Swift_SmtpTransport::newInstance('smtp.live.com', 587,) ->setUsername('myemail@domain.com') ->setPassword('******'); The error I get is to long to post it hree... You can see it on my domain: http://oli4tje.3owl.com/PEAR/Swiftmailer/test.php Greetz – Olivier Peeters Mar 08 '13 at 09:13
  • This is the configuration that works with me: $transport = Swift_SmtpTransport::newInstance('smtp.live.com', 587, 'tls'); $transport->setAuthMode('login'); – vjnrv Mar 20 '13 at 14:09
0

You need to set the encryption to tls as the 3rd parameter:

$transport = Swift_SmtpTransport::newInstance('smtp.life.com', 25, 'tls')

Most probably port should also be set to 587

Sergiu Sandrean
  • 521
  • 5
  • 11