문제

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"));'

다른 팁

Try to use the IP address 74.125.206.109 instead of domain name (smtp.gmail.com)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top