0

My emails that are send by mail() are getting directly into the spam box, tested with GMAIL and HOTMAIL. So:

  • I have dedicated server

  • My server ip is not listed on any blacklists

This is my code:

function send_email($recipient, $sender, $subject, $email_body){
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$sender;
mail($recipient,$subject,$email_body,$headers);
}

$from = 'info@domain.com';
$subject    = 'subject';
$email_body = '<h1 style="text-align:center;">Title</h1><p>Message</p>';
send_email($userbday['email'], $from, $subject, $email_body);

Any thoughts?

llanato
  • 2,508
  • 6
  • 37
  • 59
Speedwheelftw
  • 393
  • 6
  • 19

2 Answers2

1

Try to setup an SPF record for your domain.

Also

Email is serious business.

Try transactional email service providers

Olaitan Mayowa
  • 703
  • 6
  • 10
0

It may be that your email looks exactly as spam. It sometimes happens... All my applications sends email - depending on how the client prepare the email templates - some are treated as spam almost instantly, some not.

Setting SPF Record can help, but also check (and use) some blacklist emails for your own good - like people who dont want to receive your emila should never be bothered again as they can trigger your server to be in the black lists (for example spamcop).

Seti
  • 2,169
  • 16
  • 26
  • How can I setup SPF Record? – Speedwheelftw Apr 25 '14 at 13:42
  • This is what i found by happy google searching (and it is quite simple) https://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/ Also if you want some information about the SPF itself here is nice wiki article http://en.wikipedia.org/wiki/Sender_Policy_Framework – Seti Apr 25 '14 at 13:50