【发布时间】:2016-08-27 12:17:25
【问题描述】:
嗨,当我执行 mailtest.php 时,我的 phpmailer 会产生以下结果
无法发送邮件。邮件程序错误:SMTP 连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我在这个论坛上遇到了很多关于 phpmailer 的问题,但没有一个对我有用。
我的邮件测试.php
<?php
require ("/phpmailer/PHPMailerAutoload.php");
require ("/phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'thethih@gmail.com'; // SMTP username
$mail->Password = 'password.'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('thethih@gmail.com', 'Joe User'); // Add a recipient
$mail->addAddress('thethih@yahoo.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
任何帮助将不胜感激..它位于本地主机中。
【问题讨论】:
-
隐藏您的凭据!!
-
密码。不是实际密码..谢谢
-
@JoseManuelAbarcaRodríguez 还没有工作
-
你也应该取消注释
//$mail->SMTPDebug = 3;那是你的内置调试器。 -
我们可以假设您阅读了 phpMailer 为您生成的链接?还是我们应该复制该部分供您在这里阅读并浪费我们和您的时间???