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:
I tried to test mail() function. It works good.
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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With