Search code examples
phpphpmailer

php mailer Message denied for spoofing attempt via SMTP Auth


Here is my code:

function send_mail($email,$message,$subject)
{                       
    require_once('mailer/class.phpmailer.php');
    $mail = new PHPMailer();
    $mail->IsSMTP(); 
    $mail->SMTPDebug  = 2;                     
    $mail->SMTPAuth   = true;                  
    $mail->SMTPSecure = "tls";                 
    $mail->Host       = "";      
    $mail->Port       = 587;             
    $mail->AddAddress($email);
    $mail->Username="n";  
    $mail->Password="";            //correct password
    $mail->SetFrom('','');
    $mail->AddReplyTo("","");
    $mail->Subject    = $subject;
    $mail->MsgHTML($message);
    $mail->Send();
}   

and my debug output:

SMTP -> FROM SERVER:220-md-in-79.webhostbox.net ESMTP Exim 4.87 #1 Fri, 04 Aug 2017 11:09:34 +0000 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. SMTP -> FROM SERVER: 250-md-in-79.webhostbox.net Hello [103.53.43.68] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP SMTP -> FROM SERVER:220 TLS go ahead SMTP -> FROM SERVER: 250-md-in-79.webhostbox.net Hello [103.53.43.68] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP SMTP -> FROM SERVER:250 OK SMTP -> FROM SERVER:250 Accepted SMTP -> FROM SERVER:354 Enter message, ending with "." on a line by itself SMTP -> FROM SERVER:250 Message denied for spoofing attempt via SMTP Auth

I am using a Hostgator server


Solution

  • Your mail provider wants to avoid any kind of email spoofing originating from their servers. You will have to use your username in the From field:

    $mail->SetFrom('[email protected]','QuickDawa');