【发布时间】:2015-01-19 04:50:51
【问题描述】:
我在网上搜索了这个问题,但没有一个能解决我的问题。我正在尝试使用 PHPMailer 发送单个邮件。但我的浏览器屏幕出现此错误。
SMTP -> FROM SERVER:
SMTP -> ERROR: RSET failed:
SMTP -> FROM SERVER:
SMTP -> ERROR: MAIL not accepted from server:
The following From address failed: mymailid@gmail.com : MAIL not accepted from server,,
SMTP server error:
Mailer Error: The following From address failed: mymailid@gmail.com : MAIL not accepted from server
我发送邮件的代码是。
<?php
require_once('mailer/class.phpmailer.php');
date_default_timezone_set('Asia/Kolkata');
$to = $_POST['to'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$mail = new PHPMailer();
$mail -> SMTPDebug = 2;
$mail -> IsSMTP();
$mail -> SMTPSecure = 'tls';
$mail -> Host = 'smtp.gmail.com';
$mail -> Port = 587;
$mail -> SMTPAuth = true;
$mail -> Username = 'mymailid@gmail.com';
$mail -> Password = '*********';
$mail -> setFrom("mymailid@gmail.com","Name");
$mail -> addReplyTo("mymailid@gmail.com","Name");
$mail -> Subject = $subject;
$mail -> msgHTML($msg);
$mail -> addAddress($to);
if(!$mail -> send()) {
echo "<h3>Mailer Error: ". $mail-> ErrorInfo . "</h3>";
}
else {
echo "<h1>Email Sent Successfully.</h1>";
}
?>
请帮我解决这个问题。提前致谢。
【问题讨论】:
-
Manoj Kumar,替换这些然后尝试,1] 将
$mail -> SMTPSecure = 'tls';替换为 ` $mail -> SMTPSecure = 'ssl'; 2] replace$mail -> Port = 587; ` 与 ` $mail -> 端口 = 465; `(两者都可以,但如果出错,请使用这个) -
不,不要那样做。您不应该使用 ssl - 它自 1998 年以来已被弃用,并且不会对您的问题产生影响,并且此错误是在建立安全连接之后出现的。如果您发布完整的 SMTP 记录,这将有所帮助 - 向我们展示导致错误的原因,而不仅仅是之后发生的事情。
-
感谢您的回复。我还在我的 Gmail 帐户中启用了“允许不太安全的应用程序访问”选项。仍然错误是一样的。
-
你有没有设法解决这个问题?
-
没有。我没有解决这个问题。
标签: php email smtp gmail phpmailer