I know this question has a bunch of answers like this on SO already, but none of the solutions seem to work for me.
I am trying to send an email from my Google Apps domain. Letters are sent most of the time, but sometimes this exception gets and the letter is not sent.
Uncaught PHP Exception Swift_TransportException: "Expected response code 220 but got code "", with message """ at C:\HostingSpaces\abc\domain.com\wwwroot\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php line 383 {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 220 but got code \"\", with message \"\" at C:\\HostingSpaces\\abc\\domain.com\\wwwroot\\vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Transport\\AbstractSmtpTransport.php:383)"} []
Yes, I use SSL, yes, I gave access to less secure applications, and yes, I use port 465. I turned on buffering so that the application wouldnโt crash because the exception didnโt get there.
My config.yml below
swiftmailer:
transport: smtp
host: smtp.gmail.com
username: no-reply@googledomain.com
password: password
port: 465
encryption: ssl
spool: { type: memory }
And my email class is below
public function send_new_order_email($entity) {
try{
$message = $this->getEmailObj("toaddress@gmail.com");
$message->setBody(
$this->renderView(
'APIBundle:Emails:ops_neworder.html.twig',
array('entity' => $entity)
),
'text/html'
)->setSubject('New Order : '.$entity->getId());
$this->container->get('mailer')->send($message);
}
catch(Exception $e){}
}
private function getEmailObj($email){
$message = \Swift_Message::newInstance()
->setFrom('no-reply@googledomain.com')
->setTo($email);
return $message;
}
Do you have any suggestions to make this work?