PHP mails always ends up in the spam folder
i have an issue here, my mails sent from my PHP script never gets delivered to my inbox, but spam instead. Any help on how to get it to the inbox. Thank y'all Here is my code sample
public function sendMail($name,$email,$message)
{
$this->validateInput($name,"Empty Name","Invalid Name");
$this->validateEmail($email,"Empty Email","Invalid Email");
$this->validateLargeData($message,"Invalid Message","Empty Message","Message Too Short");
if (empty($this->errors))
开发者_开发技巧{
$fromName = $name;
$fromEmail = $email;
$from = "From: $fromName <$fromEmail>\r\n";
$reply = "Reply-To: $fromEmail\r\n";
$mime = "MIME-Version: 1.0\r\n";
$content = "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers = $from.$reply.$mime.$content;
if (mail("support@findit.com.ng","Contact",$message,$headers))
{
echo "<div class='success1'>Thank you $name, we will get back you immediately.</div>";
}
}
else
{
echo "<div class=''>";
echo "</div>";
}
}
edit Pls here is the header information i am using
$fromName = $name;
$fromEmail = $email;
$from = "From: $fromName <$fromEmail>\r\n";
$reply = "Reply-To: $fromEmail\r\n";
$mime = "MIME-Version: 1.0\r\n";
$content = "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mailer = "X-Mailer: PHP's mail() Function";
$headers = $from.$reply.$mime.$content.$mailer;
@cyberomin
Make sure your headers are complete:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "From: aaa.bbb <aaa@bbb.ccc>\n";
$headers .= "X-Mailer: PHP's mail() Function\n";
mail("xxx@yyy.zzz", "subject","message",$headers);
And if you are on shared hosting, it might be that there's a blacklisted spammer on your ip.
The best suggestion I can probably make is to try a different way of sending your emails. For example phpmailer or Swift Mailer.
We can only give you an exact answer if you give us the headers of the mail in your spam folder, but I think that it's because you are sending from a computer that has an IP in an IP range that contains consumer internet connections. Email from consumer computers usually is spam.
精彩评论