【发布时间】:2017-08-19 19:51:19
【问题描述】:
目前我正在本地测试我的电子邮件格式和电子邮件发送。我使用 XAMPP 并“设置”了 Mercury 邮件服务器。我没有更改任何内容并创建了一个新用户。
这是本地用户的照片:
然后,我在 PHP 中有这个(不是所有的代码,而是重要的部分):
$mailer = new mailer\Mailer();
$mailer->setCustomSettings();
// Some addAddress, From, subject and content variables are set here....
$mailer->send();
然后setCustomSettings 看起来像这样:
public function setCustomSettings() {
$this->CharSet = 'UTF-8';
$this->isSMTP();
$this->Host = 'localhost';
$this->SMTPAuth = true;
$this->Username = 'Admin';
$this->Password = '*******';
//$this->SMTPSecure = 'tls';
$this->Port = 25;
$this->imapHost = '127.0.0.1';
}
现在,我希望它会起作用,但不幸的是它没有。我收到以下错误:
<b>Fatal error</b>: Uncaught exception 'mailer\phpmailerException' with message 'SMTP Error: Could not authenticate.' in D:\xampp\htdocs\FOLDER\classes\mailer\PHPMailer.php:1352
我知道我的密码是正确的,你可以看到用户存在,我可以在我的电子邮件上登录 Roundcube。
使用SMTPDebug 我得到以下输出:
2017-03-27 07:57:18 SERVER -> CLIENT: 220 localhost ESMTP server ready.
2017-03-27 07:57:18 CLIENT -> SERVER: EHLO SOMENAME.local
2017-03-27 07:57:18 SERVER -> CLIENT: 250-localhost Hello SOMENAME.local; ESMTPs are:
250-TIME
250-SIZE 0
250 HELP
2017-03-27 07:57:18 CLIENT -> SERVER: QUIT
2017-03-27 07:57:18 SERVER -> CLIENT: 221 localhost Service closing channel.
2017-03-27 07:57:18 SMTP Error: Could not authenticate.
【问题讨论】:
-
尝试使用
$this->SMTPDebug = 2;启用调试器 -
查看我编辑后的输出。
-
尝试指定
Username = "root@localhost" -
还是不行。