Swiftmailer Caught exception: expected response code 250, but received code ", with message" "

I'm having problems with symfony 1.4 swiftmailer. When I try to use the sendmail () function, I received an error code:

Caught exception: Expected response code 250 but got code "", with message "" 

And symfony does not send messages.

Below is my sendmail function

 static function sendmail($mail, $textmessage, $subject) { try { $message = Swift_Message::newInstance() ->setFrom(sfConfig::get('app_mail_address_from')) ->setTo($mail) ->setSubject($subject) ->setBody($textmessage) ->setContentType("text/html"); // sfContext::getInstance()->getMailer()->send($message); sfContext::getInstance()->getMailer()->send($message); // mail("mymailcom", "A subject", "A message", "FROM: noreply@mail.com "); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } 

What I tried to do:

  • I tried to check the mail () function. It works well.

  • I tried changing smtp settings to gmail account - not working

My server: CentOs6 on the server godaddy.co.uk

Can someone please help me with this error?

+5
source share
1 answer

Ok, the post from the comment helped, maybe someone will use this: I think the problem is swiftmailer:

  try { $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance('Subject') ->setFrom(sfConfig::get('app_mail_address_from')) ->setTo($mail) ->setSubject($subject) ->setBody($textmessage) ->setContentType("text/html"); $mailer->send($message); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n";die; } 

This is working code.

+4
source

Source: https://habr.com/ru/post/1204419/


All Articles