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:
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.