Forum Moderators: coopster

Message Too Old, No Replies

mail() error

server error for some calls to mail()

         

daosmith

2:04 am on Dec 12, 2003 (gmt 0)

10+ Year Member



Hi all,

For some reason a particular call to mail() that I make is crashing my PHP error script; it works fine in other scripts, but not here. I'm certain it is mail() that is the problem, as if I remove the call then everything works.

Basically the situation is that the script does a lookup in the database for an error message, but if it can't find one then I want it to get the generic message and email the web admin. A cut-down script snippet follows: -

$error = mysql_query("SELECT err_msg
FROM _website_err
WHERE err_id = '$error_code'");

/* If no error message was returned, return the generic msg and email the webadmin. */

if (mysql_num_rows($error) == 0) {

$error = mysql_query("SELECT err_msg
FROM _website_err
WHERE err_id = -1");

mail("$email", "email error", "blah...");
}

If I remove the call to mail() everything works perfectly, but even using as simple a call as that above gives me a 500 Internal Server error.

Any suggestions would be much appreciated!

Timotheos

4:22 pm on Dec 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only question I would have is about the $email variable.

What happens if you just put in a valid email address?

mail("me@example.com", "email error", "blah...");

daosmith

2:03 am on Dec 13, 2003 (gmt 0)

10+ Year Member



I've tried having just a regular email address - but even if $email were invalid you would still expect mail() to return; not display the internal server error page.

mogwai

1:28 pm on Dec 13, 2003 (gmt 0)

10+ Year Member



Have you checked that your mailer software is functioning okay? can you mail out from the box not using php? If so you should check that everything is configured correctly in php.ini.