Using PHPMailer 5.2 .
When mails sent through phpmailer ends up in spam folder .
On testing ip it was working fine , used to receive mails to inbox only . Once it was hosted on live domain , the mails are going to spam folder .
Using gmail smtp credentials.
Below is the code i am using to access phpmailer .
<?php
require 'phpmailer/class.phpmailer.php';
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$message = $_REQUEST['message'] ;
$subject = 'Enquiry' ;
$email_status='';
$message_body='';
$message_body='
Hello,<br>
<p>You have a enquiry request below</p>
<table>
<tr>
<td>Name</td><td>'.$name.'</td>
</tr>
<tr>
<td>Email</td><td>'.$email.'</td>
</tr>
<tr>
<td>Message</td><td>'.$message.'</td>
</tr>
</table>
<br>
Thank you,<br>
Support Team
';
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
//$body = file_get_contents('contents.html');
$body = $message_body;
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 587; // set the SMTP server port
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Username = "mymail@gmail.com"; // SMTP server username
$mail->Password = "12345"; // SMTP server password
$mail->IsSendmail(); // tell the class to use Sendmail
// $mail->AddReplyTo("mymail@gmail.com","mymail");
$mail->From = "mymail@gmail.com";
$mail->FromName = "mymail";
$to = "yourmail@gmail.com";
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
$email_status='success';
// echo 'Message has been sent.';
// echo "<script>alert('Thank you . We will get back to you soon.');document.location='contact.php'</script>";
} catch (phpmailerException $e) {
//echo $e->errorMessage();
$email_status='fail';
}
header( 'Location: contact.php?email_status='.$email_status);
?>
Any suggestions on this . should i do any modification for phpmailer class .