1

我一直在尝试设置 google 企业电子邮件 smtp。我使用自己的电子邮件地址 (username@mydomain.me) 创建了一个帐户。这是由 gmail 托管的。

我在 Heroku 上使用 phpMailer 类。我已经取消了 php.ini 文件中 php_openssl.dll 的注释。

我不断收到此错误:

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.

有谁知道这里出了什么问题?

 ...
 $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

弄清楚了!诀窍是“tls”而不是 ssl!

    $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

尝试这个

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

应该管用

参考:- 1 2

于 2013-01-18T23:54:46.627 回答