mail(); delivery times widely varied

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

mail(); delivery times widely varied

Post 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);
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

i had suspected that, but i just wanted to double check.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply