【发布时间】:2015-09-12 12:20:02
【问题描述】:
我无法使用 PHPMailer 连接到 SMTP GMAIL。
这里是错误:
2015 年 6 月 25 日下午 22:54 出错 - stream_socket_client():无法 连接到 smtp.gmail.com:587(连接超时) /home/amiroper/public_html/beporsbedoon/app/helpers/phpmailer/smtp.php 在第 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代码错误或者是连接问题
【问题讨论】:
-
这是一个连接问题 - 您的 DNS 不工作。