Page 1 of 1

Error sending mail Swift v4.0.3

Posted: Fri May 15, 2009 4:48 pm
by HELLOHAOS
Hello.
I'm upload Swift Mailer library v4.0.3.

I wrote a simple code (take from the documentation ):

Code: Select all

 
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
$mailer = Swift_Mailer::newInstance($transport);
 
$message = Swift_Message::newInstance($param['subject'])
          ->setFrom(array($param['from']))
          ->setTo(array($param['to']))
          ->setBody($param['text']);
 
$mailer->send($message);
 

When try to send a mail to get an error:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 220 but got code "", with message ""' in /cms/Modules/Mail/Swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php:416 Stack trace: #0 /cms/Modules/Mail/Swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(309): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array) #1 /cms/Modules/Mail/Swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php(117): Swift_Transport_AbstractSmtpTransport->_readGreeting() #2 /sata1/cms/Modules/Mail/Swift/lib/classes/Swift/Transport/SendmailTransport.php(71): Swift_Transport_AbstractSmtpTransport->start() #3 /cms/Modules/Mail/Swift/lib/classes/Swift/Mailer.php(84): Swift_Transport_SendmailTransport->start() #4 /cms/M in /cms/Modules/Mail/Swift/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 416

I have not found a problem in my code, or people with the same problem.

Maybe someone here can help me?

Re: Error sending mail Swift v4.0.3

Posted: Wed May 20, 2009 4:06 pm
by HELLOHAOS
No ideas? :cry:

Re: Error sending mail Swift v4.0.3

Posted: Mon Sep 07, 2009 12:04 pm
by reddevilv11
It doesn't work for the author, but i had the same problem and i got the same trace.

The problem was about the server configuration. I you want to test, here's an example using gmail:

Code: Select all

 
/*It's symfony config, if you don't use symfony put: require_once 'lib/swift_required.php'; */
/* My route file was lib/vendor/swift, put your own route in any case. */
require_once sfConfig::get('sf_lib_dir').'/vendor/swift/swift_init.php'; 
 
 
/* Of course write a valid gmail account, my problem was that gmail needs ssl option*/
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
  ->setUsername('gmailuser')
  ->setPassword('passwordgmailuser')
  ;
 
  $mailer = Swift_Mailer::newInstance($transport);
 
 
$message = Swift_Message::newInstance()
 
//Give the message a subject
  ->setSubject('Your subject')
 
  //Set the From address with an associative array
  ->setFrom(array('user@yourdomain.com' => 'Author))
 
  //Set the To addresses with an associative array
  ->setTo(array('reciever@domain.com' => 'Reciever'))
 
  //Give it a body
  ->setBody('Testing swift mail');
 
  $result = $mailer->send($message);
 
 
I hope it helps you