What are the requirements for mail() to return TRUE for "accept for delivery"
| From: | Mike Zornek | Date: | Tue, 04 May 2004 19:35:55 +0000 |
| Subject: | What are the requirements for mail() to return TRUE for "accept for delivery" | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-185342@lists.php.net to get a copy of this message | ||
In my script I am doing a SQL call to get a list of email addresses (approx
50 of them), I then run a while loop to send individual emails. I'm running
into a situation where the script hangs on certain mail calls. The page code
stops coming in and then eventually the browser will timeout at 60 seconds.
I believe the script is continuing to run on the server as my own name is at
the bottom of the list and I will still get the email, in time.
In the documentation it says:
> mail() returns TRUE if the mail was successfully accepted for delivery
It it my understanding that mail will use sendmail, and will return true
after sendmail accepts delivery. My question is then, what does sendmail do
before it will accept delivery? What is hanging my script?
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
echo "<!--\n";
print_r($row);
echo "-->\n";
$email_address = "" . $row['email'] . "";
if (is_string($email_address)) {
echo "<!--\n";
echo "Sure looks like a string to me.";
echo "-->\n";
} else {
echo "<!--\n";
echo "Not a string, I'm a: " . gettype($email_address);
echo "-->\n";
}
if (mail($email_address, "ASMP Find a Photo Request", $message,
"From: webmaster@asmp.org\r\n"
."Reply-To: webmaster@asmp.org\r\n"
."X-Mailer: PHP/" . phpversion()
)
) {
echo "<br>Email was sent to <strong>" . $email_address .
"</strong>
successfully.";
} else {
echo "<br><strong>Email was not sent! Contact
zornek@asmp.org</strong>.";
}
}
Even with the script "working" after the timeout, I still need to find out
what's causing he delay as the user of the tool needs proper confirmation
that it sent the emails.
OT: I've read on the web that doing email through sockets is the best for
mass mail such as this, but to be honest I don't see the list growing beyond
50 for the immediate future and would like to put this feature to bed for
now.
~ Mike
-----
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: <http://MikeZornek.com>
New Project: <http://WebDevWiki.com>