Re: mail() takes too much time
| From: | brian | Date: | Sun, 02 Sep 2007 22:53:05 +0000 |
| Subject: | Re: mail() takes too much time | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261623@lists.php.net to get a copy of this message | ||
shiplu wrote:
Hello everybody, I am maintaining a social network site. there each user can send other mail. these mails are not real mail rather message entry to database. I added a new feature so that every message is sent to me (admin/webmaster) via email (real e-mail). I used mail function. THis is a simple mail function. all it does sends mail with the message as the mail body to my address. Thats it. no extra complexity. But the problem is I got the mail very late. after 4-6 hours. That is huge time difference. I shouldn't take more than 3-5 mins. Do you know the reason? my mail code is here, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; list($myname,$mydomain)=preg_split("/\@/",$myemail,2); $headers .= "From: $myname <$myemail>\r\n"; mail("me@mysite.com", "message from XXX to YYY", $message_content, $headers); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This might be an issue with your MTA (Sendmail, Postfix, etc.). Have you tried sending a mail directly (ie. via shell)? Also, if it's not required that you receive a notice of each post immediately, perhaps you could instead have some process (on your computer) check the database periodically. If you go this route and you have an auto_increment id field, you should save the largest so that your script only has to retrieve messages with id > last_id. brian