Page 1 of 1

mail(); delivery times widely varied

Posted: Thu Mar 23, 2006 7:49 am
by $var
hi,

i'm using mail(); as a notification system for an issue tracker program.
it's working okay, some mail comes through as soon as you trigger it...

however, some doesn't come through for upwards of 12 hours,
which defeats the purpose for 24 hour turn-around.

has anyone ever encountered this sort of thing?
would it be a server thing, is there a way that i can better treat the script?

here is an example, some $vars are being called using $_REQUEST and some are database drawn:

Code: Select all

$mail_body = " 
Hello $name, 
Your query has been sent to $assignFName.";

$address = $assignEmail.', ';
$address .= $address2;
$subject = "[$issueID] Incident: $title";

$headers = 'From: admin@honeycombworldwide.com' . "\r\n" .
'Reply-To: admin@honeycombworldwide.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($address, $subject, $mail_body, $headers);

Posted: Thu Mar 23, 2006 7:57 am
by onion2k
This has nothing to do with PHP and everything to do with the way email works. Email is not supposed to be instantaneous, it's supposed to get there when it can. If servers routing the email are down, or slow, or badly configured then it can take a while. You shouldn't expect an email to arrive immediately.

Posted: Thu Mar 23, 2006 8:24 am
by Benjamin
The way I understand it a mail server under heavy load will just start to query the mail and send mail from the query in the order they are received. It could be your mail server or possibly the recipients. Maybe you can try another outbound mail server.

Posted: Thu Mar 23, 2006 8:48 am
by $var
i had suspected that, but i just wanted to double check.

Posted: Thu Mar 23, 2006 9:11 am
by $var
just to note. we use the same outgoing mail server for internal communication as well.
so, i sent an email about this to the guy sitting next to me, using outlook... he opened it, replied and i got the mail. pronto.

there is another layer to it i think. outlook mail corrospondance has always been immediate.
it's strickly using mail(); that the lag occurs.

Posted: Thu Mar 23, 2006 9:13 am
by pickle
If you want to be instantly informed of the issue, try sending an SMS. Many cell phone providers have the ability to send an email to a phone number - that email gets sent as a text message to the phone. The system I built does this and I usually get the message within 5 minutes of the issue being posted.

Posted: Thu Mar 23, 2006 9:32 am
by $var
thanks pickle, for the idea...
i don't think that it is applicable right now, as the email can go to any of 20 people some of which have cell phones and blackberries, some of which (mainly me, the web admin) don't have either.

so, my guess is the mail function is just slower for the system.

Posted: Thu Mar 23, 2006 10:55 am
by feyd
the mail() function is just slow, period. It's better to communicate directly with an SMTP if and when possible to send anything more than a single email.