SMTP GMAIL Connection(SMTP GMAIL 连接)
问题描述
我无法使用 PHPMailer 连接到 SMTP GMAIL.
I can't connect to SMTP GMAIL with PHPMailer.
这里是错误:
2015 年 6 月 25 日下午 22:54 出错 - stream_socket_client():无法连接到 smtp.gmail.com:587(连接超时)/home/amiroper/public_html/beporsbedoon/app/helpers/phpmailer/smtp.php在第 222 行
Error on Jun 25, 2015 22:54PM - stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection timed out) in /home/amiroper/public_html/beporsbedoon/app/helpers/phpmailer/smtp.php on line 222
这是我的代码:
$this->_mail->isSMTP();
$this->_mail->Host = "smtp.gmail.com";
$this->_mail->SMTPAuth = true;
$this->_mail->Username = "amiroperator@gmail.com";
$this->_mail->Password = "*********";
$this->_mail->SMTPSecure = "tls";
$this->_mail->Port = "587";
$this->_mail->SMTPDebug = 4;
$this->_mail->From = "AmirOperator";
$this->_mail->FromName = 'amiroperator@gmail.com';
$this->_mail->addAddress("amiroperator@outlook.com", "test");
$this->_mail->isHTML(true);
$this->_mail->Subject = 'Registration confirm';
$this->_mail->Body = 'Thank you for registering to activate your account please click on this link. ".DIR."account/activate/$id/$activasion"';
$this->_mail->AltBody = 'Thank you for registering to activate your account please click on this link. ".DIR."account/activate/$id/$activasion"';
if(!$this->_mail->send()) {
$data['mailsent'] = false;
} else {
$data['mailsent'] = true;
}
php代码错误或者是连接问题
the php code is wrong or this is connection problem
推荐答案
您的服务器无法连接到端口 587 上的 smtp.gmail.com.一个测试工具也有同样的问题:
Your server cannot connect to smtp.gmail.com on port 587. I have the same problem from a testing tool:
Resolving hostname...
Connecting...
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
Message sending failed.
在我的本地机器上,它运行良好:
From my local machine, it works perfectly:
Trying 74.125.195.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP be3sm8900765wib.21 - gsmtp
也许美国的谷歌存在暂时的问题(我在德国)或类似的问题.您的代码中没有明显的错误.您只能稍后再试一次或使用其他 SMTP 服务器.
Maybe there are temporary problems at Google from the US (I am in Germany here) or something like this. There is no obvious mistake in your code. You can only try it again later or with another SMTP server.
此外,您可以尝试直接连接 74.125.195.108(只需停用 SSL 证书验证).
Furthermore, you can try to connect with 74.125.195.108 directly (just deactivate SSL certificate validation).
也可以尝试 tls://smtp.gmail.com 作为主机.
Just also try tls://smtp.gmail.com as host.
这篇关于SMTP GMAIL 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SMTP GMAIL 连接
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
