PHPMailer - 不接受来自服务器的邮件错误


PHPMailer - Mail not accepted from server Error

我在网上搜索了这个问题,但没有一个能解决我的问题。我正在尝试使用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>";
    }
?>

请帮我解决这个问题。提前谢谢。

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