Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm having trouble in symfony 1.4 swiftmailer . When I try to use sendmail function() I got error code :

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

And symfony doesn't send messages.

Below is my function sendmail

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: [email protected]");

    } catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }


}

What I tried to do:

  1. I tried to test mail() function. It works good.

  2. I tried to change smtp settings to gmail account - not working

My Server is: CentOs6 on godaddy.co.uk server

Can somebody please help me with this error ?

like image 791
woj_jas Avatar asked Sep 29 '22 16:09

woj_jas


1 Answers

Ok , post from comment helped, maybe somebody will use that: 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

like image 82
woj_jas Avatar answered Oct 28 '22 00:10

woj_jas