On a new server I am noticing that mail is being delivered much later than it should. It does not happen all the time, but enough to where it is bothering me and want to figure out the problem.
Please do not tell me to use a mailer class or something else. I have used php's mail() for simple stuff like this years and never had a problem until now so it must be a setting or something weird on this server.
I receive the emails they are just delayed and it happens randomly it appears.
Example trace for an email (notice the sent and out time) :
Event: success success
User: user
Domain: sending.com
Sender: user@server.example.com
Sent Time: Feb 2, 2015 3:47:15 PM
Sender Host: localhost
Sender IP: 127.0.0.1
Authentication: localuser
Spam Score:
Recipient: support@receiver.com
Delivery User: -remote-
Delivery Domain:
Delivered To: support@receiver.com
Router: lookuphost
Transport: remote_smtp
Out Time: Feb 3, 2015 2:04:02 AM
ID: 1YINtp-00067R-8i
Delivery Host: receiver.com
Delivery IP: 111.111.111.111
Size: 836 bytes
Result: Message accepted
Here is the simple function I wrote and use to send mail :
// Send Mail
function send_mail($to,$from,$subject,$message)
{
// Create the email
$headers = '';
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-to: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "Message-ID: <" . md5(uniqid(time())) . "@" . $_SERVER['SERVER_NAME'] . ">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Date: " . date('r', time()) . "\r\n";
mail($to,$subject,$message,$headers);
}