PHPmailer отправляет электронную почту, чтобы охватить при использовании Gmail SMTP - PullRequest
0 голосов
/ 25 февраля 2020

Я пытаюсь отправить письмо через сервер Google. Я использовал phpmailer для настройки SMTP. Я могу отправлять электронные письма, но я обнаружил, что письма приходят в папку span. Я пытаюсь найти в Google эту проблему, и многие из них сказали мне, чтобы я видел журнал писем внутри Gmail. Я проверяю логи и там я нашел эту ошибку 'dmarc=fail (p=NONE sp=QUARANTINE dis=NONE)'. Я не знаю, как решить эту ошибку. Пожалуйста, помогите.

Вот мой PHP почтовый код:

$mail = new PHPMailer\PHPMailer\PHPMailer(); //From email address and name 


$mail->SMTPDebug = 1; 
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = 'ssl'; 
    $mail->Host = "smtp.gmail.com";

    $mail->Port = 465; 
    $mail->IsHTML(true);
    //Username to use for SMTP authentication
    $mail->Username = "sender@gmail.com";
    $mail->Password = "sender@123";
    //Set who the message is to be sent from
    $mail->setFrom('sender@gmail.com', 'Sender Name');
    //Set an alternative reply-to address
    $mail->addReplyTo('sender@gmail.com', 'Sender Name');
    //Set who the message is to be sent to
    $mail->addAddress('reciever@gmail.com', 'Reciever Name');
    $mail->AddCC('anotherReciever@gmail.com', 'Reciever Name');
    //Set the subject line
    $mail->Subject = 'Inquiry at Our Website Contact Page';
    //Read an HTML message body from an external file, convert referenced images to embedded,
    //convert HTML into a basic plain-text alternative body
    $mail->Body = "<style>tr,td{border:none;border-bottom:1px solid #fff;}table{background-color:#D63138;}</style><table border='1' width='100%'><tr><th>Name:</th><th>Email</th><th>Phone</th><th>Subject</th><th>Message</th></tr>
    <tr><td>".$name."</td><td>".$email."</td><td>".$number."</td><td>".$subject."</td><td>".$message."</td></tr></table>";
    //Replace the plain text body with one created manually
    $mail->AltBody = 'This is a plain-text message body';

    //send the message, check for errors
    if (!$mail->send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
    }
...