0

I try to send email using google server. I used phpmailer to setup SMTP. I able to send emails, but what I found is emails come in span folder. I try to search on google regarding this issue and many ones told me to see the emails log inside Gmail. I check logs and there I found this error 'dmarc=fail (p=NONE sp=QUARANTINE dis=NONE)'. I don't know how to solve this error. Please help.

Here is my PHP mailer code:

$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!";
    }
pinepain
  • 12,453
  • 3
  • 60
  • 65
Pranay kumar
  • 1,983
  • 4
  • 22
  • 51
  • is this you are looking for: https://stackoverflow.com/questions/16048347/unable-to-send-email-using-gmail-smtp-server-through-phpmailer-getting-error-s – Guarav Feb 25 '20 at 09:08
  • @Guarav thanks but your mentioned question is related to SMTP auth error. I am able to send an email. Instead of any error, my mail got into span folder. – Pranay kumar Feb 25 '20 at 12:26
  • There's nothing wrong with your code. That error means you need to set up your SPF, DKIM, and DMARC config, and there are plenty of tools that will help you inspect those settings. – Synchro Feb 26 '20 at 02:35

0 Answers0