PHP 邮件程序 "Relaying denied. Proper authentification required"
PHPMailer "Relaying denied. Proper authentification required"
我对 PHPMailer 有疑问。当我的网站上填写了某个表格(其中包含表格的信息)时,我想自己给自己发送一个电子邮件表格,但我无法让它工作。 PHP 没有发送任何错误(我确定它已启用),但是使用 SMTPDebug,我得到这个:
2015-02-12 07:35:58 CLIENT -> SERVER: EHLO localhost
2015-02-12 07:35:58 CLIENT -> SERVER: MAIL FROM:
2015-02-12 07:35:58 CLIENT -> SERVER: RCPT TO:
2015-02-12 07:35:58 SMTP ERROR: RCPT TO command failed: 550 5.7.1 ... Relaying denied. Proper authentication required.
2015-02-12 07:35:58 CLIENT -> SERVER: QUIT
2015-02-12 07:35:58 SMTP Error: The following recipients failed: me@mydomain.com
这是代码示例:
require("PHPMailer-master/PHPMailerAutoload.php");
$mail = new phpmailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->Host = "smtp.server.com"; //Mod
$mail->From = "me@mydomain.com"; //Mod
$mail->FromName = "Automatic e-mail, no reply";
$mail->AddAddress("me@mydomain.com"); //Mod
$mail->Subject = "A student forgot his password";
$mail->Body = $class.'\r\n'.$fname.' '.$lname;
$mail->WordWrap = 70;
if(!$mail->Send())
$sent = false;
else
$sent = true;
(行尾的//Mod
表示我出于隐私原因修改了数据。)
现在我读到一些人通过评论这一行解决了这个问题:
mail->IsSMTP();
但是当我这样做时我只会得到另一个错误:
Could not instantiate mail function
这对我来说似乎很合乎逻辑。
服务器需要经过身份验证的有效用户,您需要添加授权凭据。当然,更改 SMTP 服务器中有效授权凭据的用户名和密码的值。
$mail->SMTPAuth = true;
$mail->Username = "yourauthorizeduser"; // It could be your@authorized.user"
$mail->Password = "v3rys3cr3t";
我对 PHPMailer 有疑问。当我的网站上填写了某个表格(其中包含表格的信息)时,我想自己给自己发送一个电子邮件表格,但我无法让它工作。 PHP 没有发送任何错误(我确定它已启用),但是使用 SMTPDebug,我得到这个:
2015-02-12 07:35:58 CLIENT -> SERVER: EHLO localhost
2015-02-12 07:35:58 CLIENT -> SERVER: MAIL FROM:
2015-02-12 07:35:58 CLIENT -> SERVER: RCPT TO:
2015-02-12 07:35:58 SMTP ERROR: RCPT TO command failed: 550 5.7.1 ... Relaying denied. Proper authentication required.
2015-02-12 07:35:58 CLIENT -> SERVER: QUIT
2015-02-12 07:35:58 SMTP Error: The following recipients failed: me@mydomain.com
这是代码示例:
require("PHPMailer-master/PHPMailerAutoload.php");
$mail = new phpmailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->Host = "smtp.server.com"; //Mod
$mail->From = "me@mydomain.com"; //Mod
$mail->FromName = "Automatic e-mail, no reply";
$mail->AddAddress("me@mydomain.com"); //Mod
$mail->Subject = "A student forgot his password";
$mail->Body = $class.'\r\n'.$fname.' '.$lname;
$mail->WordWrap = 70;
if(!$mail->Send())
$sent = false;
else
$sent = true;
(行尾的//Mod
表示我出于隐私原因修改了数据。)
现在我读到一些人通过评论这一行解决了这个问题:
mail->IsSMTP();
但是当我这样做时我只会得到另一个错误:
Could not instantiate mail function
这对我来说似乎很合乎逻辑。
服务器需要经过身份验证的有效用户,您需要添加授权凭据。当然,更改 SMTP 服务器中有效授权凭据的用户名和密码的值。
$mail->SMTPAuth = true;
$mail->Username = "yourauthorizeduser"; // It could be your@authorized.user"
$mail->Password = "v3rys3cr3t";