Every time I try to send an email through a google apps account with swiftmailer in symfony 2.3.11, I get the following message
Connection could not be established with host smtp.gmail.com [php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution #0] 500 Internal Server Error - Swift_TransportException
I googled it but I didn't get any results so I must be doing something wrong.
config.yml
# Swiftmailer Configuraftion swiftmailer:
transport: gmail
username: info@*******.com
password: **
Controller that sends email :
/* send an email to user */
$message = \Swift_Message::newInstance()
->setSubject('Thank you')
->setFrom('info@********.com')
->setTo($email)
->setBody(
$this->renderView(
'xyProfileBundle:Mailer:thankyou.html.twig',
array('email' => $email, 'token' => $token)
)
)
->setContentType("text/html");
$this->get('mailer')->send($message);
How can I fix this?
It looks like your host is not able to resolve smtp.gmail.com.
Try to ping it:
ping smtp.gmail.com
And:
php -r 'var_dump(gethostbyname("smtp.gmail.com"));'