【问题标题】:PHPMailer - Mail not accepted from server ErrorPHPMailer - 邮件不接受来自服务器错误
【发布时间】: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 -&gt; SMTPSecure = 'tls'; 替换为 ` $mail -> SMTPSecure = 'ssl' ; 2] replace $mail -> Port = 587; ` 与 ` $mail -> 端口 = 465; `(两者都可以,但如果出错,请使用这个)
  • 不,不要那样做。您不应该使用 ssl - 它自 1998 年以来已被弃用,并且不会对您的问题产生影响,并且此错误是在建立安全连接之后出现的。如果您发布完整的 SMTP 记录,这将有所帮助 - 向我们展示导致错误的原因,而不仅仅是之后发生的事情。
  • 感谢您的回复。我还在我的 Gmail 帐户中启用了“允许不太安全的应用程序访问”选项。仍然错误是一样的。
  • 你有没有设法解决这个问题?
  • 没有。我没有解决这个问题。

标签: php email smtp gmail phpmailer


【解决方案1】:

Gmail 认为您的电子邮件和密码不正确。您应该使用真实凭据进行身份验证,否则他们会阻止它

【讨论】:

  • 我正在使用我的真实 Gmail 帐户密码。
  • 在没有 setFrom 的情况下尝试使用它
  • @InyaProduction,使用 setFrom 是可以的,没有任何问题。
  • 感谢您的回复。我还在我的 Gmail 帐户中启用了“允许不太安全的应用程序访问”选项。仍然错误是一样的。
猜你喜欢
  • 2018-12-08
  • 2016-01-05
  • 2012-03-18
  • 2013-03-05
  • 2017-01-19
  • 1970-01-01
  • 1970-01-01
  • 2016-07-20
  • 1970-01-01
相关资源
最近更新 更多