1

I've been trying to set up google business email smtp. I've created an account with my own email address (username@mydomain.me). This is hosted by gmail.

I'm using the phpMailer class on Heroku. I've already uncommented the php_openssl.dll in the php.ini file.

I keep getting this error:

ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) SMTP Error: Could not connect to SMTP host.

Does anyone know what is going wrong here?

 ...
 $mail->Host = "ssl://stmp.gmail.com";
 $mail->SMTPDebug  = 2;  
 $mail->SMTPAuth   = true;
 $mail->Port       = 587;
 $mail->SMTPSecure = 'ssl'; 
 $mail->Username   = "username@myDomain.me";
 $mail->Password   = "mypassword";
 $mail->SetFrom('username@myDomain.me', '...');
 $mail->AddReplyTo("an@email.co", '');
 $mail->Subject = '...';
 ...
4

2 に答える 2

4

理解した!トリックはsslではなく「tls」でした!

    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "mail.mydomain.me"; // SMTP server
    $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                               // 1 = errors and messages
                                               // 2 = messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "name@mydomain.me";  // GMAIL username
    $mail->Password   = "pass";            // GMAIL password
于 2013-01-19T17:11:33.827 に答える
0

try this

$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->SMTPSecure = "ssl";
$mail->Port = 465; 

should work

reference :- 1 2

于 2013-01-18T23:54:46.627 に答える