0
votes

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

2

2 Answers

1
votes

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('info@quickdawa.in','QuickDawa');
0
votes

Firstly, I can tell that you're using a very old version of PHPMailer - get the latest.

The reason it's saying you're spoofing is because you're spoofing...

You're sending through mail.quickdawa.in using a from address of quickdawa@gmail.com, but gmail doesn't list your host as a valid source for gmail.com addresses, so you are failing an SPF check.

If you want to send from a gmail address, you need to send through gmail. See the gmail example provided with PHPMailer for how to do that.

Alternatively, send from the address you log in with.