Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
phpMailer从Heroku到gmail业务?_Php_Heroku_Gmail_Phpmailer - Fatal编程技术网

phpMailer从Heroku到gmail业务?

phpMailer从Heroku到gmail业务?,php,heroku,gmail,phpmailer,Php,Heroku,Gmail,Phpmailer,我一直在尝试设置谷歌商务邮件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

我一直在尝试设置谷歌商务邮件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 = '...';
 ...
试试这个

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

参考资料:-

试试这个

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


参考资料:-

找到了!诀窍是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

明白了!诀窍是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


$mail->Host=ssl://stmp.gmail.com; 在文档中查看此内容,我觉得这是错误的,ssl可能会被单独定向在一些博客文章中将其称为ssl。。。我们最初的版本是w/o.@NewBee,我们确实定义了PHPMailer,只是没有在摘录中,对不起。我们有行$Mail->Port=587,这就是问题所在吗?我们有SMTPSecure,它在我给出的代码中。请参阅更新的答案,端口需要更改$Mail->Host=ssl://stmp.gmail.com; 在文档中查看此内容,我觉得这是错误的,ssl可能会被单独定向在一些博客文章中将其称为ssl。。。我们最初的版本是w/o.@NewBee,我们确实定义了PHPMailer,只是没有在摘录中,对不起。我们有行$Mail->Port=587,这就是问题所在吗?我们有SMTPSecure,它在我给出的代码中。请参阅更新的答案,端口需要更改$Mail->SMTPDebug=1;看看到底发生了什么然后抱歉兄弟,去搜索php\u网络\u getaddresses:getaddrinfo失败:,可能会帮助你考虑升级投票来帮助我吗?谢谢你的努力。你的问题解决了吗?如果是,请更新答案或添加您自己的答案最终解决!我马上就发布。$mail->SMTPDebug=1;看看到底发生了什么然后抱歉兄弟,去搜索php\u网络\u getaddresses:getaddrinfo失败:,可能会帮助你考虑升级投票来帮助我吗?谢谢你的努力。你的问题解决了吗?如果是,请更新答案或添加您自己的答案最终解决!我马上就发。