PHP mail question

I do not use PHP but we have recently paid for some web pages to be done with contact forms on, the problem is the emails are taking ages to come through (around an hour). On looking at the code it uses “X-Mailer: PHP/” to send the mail. (I use ASP.net and SQLMail on my pages). On my pages the emails arrive within minutes but on these PHP pages they take ages (both use the same mail account and web servers) so can anyone let me know what we need to be asking of the developers. thanks

Need to look at the host and the frequency of the sending emails. Could be its getting stuck in the spam filter, then being released.

thanks for the reply - the emails are not often at all - maybe even one a day but i will check the mail server it arrives at, thanks

I had one site that was using SMTP with authentication and it was delayed like you mentioned.
The PHP site did not need to use SMTP and removing it solved the delay. You might want to check
how the PHP is sending the emails. Or post the code for us to peek at…

i have gone into the page and this seems the be the code that sends the email from the form

[php]<?php
if (isset($_POST[‘submit’])) {

$name = $_POST['Name'];
$phone = $_POST['Phone'];
$email = $_POST['Email'];
$date=gmdate("d-m-Y H:i");

$youraddress = "[email protected]";
$emailsubject = "my email subject";
$bodyemail = "A new enquiry has been received on $date.\n\n
			Name: $name\n\n
			Email: $email\n\n
			Phone: $phone\n\n\n
";
$extra = "From: $name <" . $email . ">\r\n" . "X-Mailer: PHP/" . phpversion();
mail($youraddress, $emailsubject, $bodyemail, $extra);
print "<script>";
print "self.location='thanks.html';";
print "</script>"; 

} else { ?>[/php]

That mail code is standard not SMTP.

It should work. And, you said it does. But, slow emails. This has to be either the server or the email client.
I have seen this on emails to AOL. Often happens with AOL. I have also seen where the mail client is set
to receive mail on a schedule and it’s set too high.

Who is your hosting company? Perhaps they have some some of delay.
I know a couple of ISP’s in the area that delay mail thru levels of SPAM filters like Richei did already mention.

Another test would be to create a small short PHP script that just emails one simple email and execute it.
That would rule out other areas of your site causing the delay. Not much help, I guess…

ive also seen cases where it was delayed due to insufficient headers

Richei!!! You said that to make me look, didn’t you! LOL… Yes that could be it!
Most servers these days will check emails for valid return addresses. Perhaps the server he is using
needs the reply-to in the headers…

Well, anyway, if so, this is an example of a standard setup for headers:
$headers = ‘From: [email protected]’ . “\r\n” .
‘Reply-To: [email protected]’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

(He called his extras…)
So, Andy, try changing this line:
$extra = “From: $name <” . $email . “>\r\n” . “X-Mailer: PHP/” . phpversion();
To this version:
[php]
$extra = “From: $name <” . $email . “>\r\n” . "Reply-To: " . $email . “\r\n” . “X-Mailer: PHP/” . phpversion();
[/php]
Let us know if that does it…

thanks for the help - will give it a go.

btw the hosting server for the page is our hosting company and this then is sent straight to our exchange mail server.

Well, if it is exchange-server receiving the mail, it could be some setting in that. Exchange has a ton of rules, optional settings and may be delaying it. Try sending the email to your personal mail or someone’s email outside of exchange and see if it gets there quickly. That would rule out the Exchange-Server. (Don’t try it with AOL as they are slow and would not be a good test!)

Good luck with it…

Sponsor our Newsletter | Privacy Policy | Terms of Service