Page 1 of 1

emil error

Posted: Fri Feb 17, 2006 2:08 am
by jaylin
when i test this code

Code: Select all

$to  = $_REQUEST["txtto"];
$subject = $_REQUEST["txtsubject"];
$message = "'" . $_REQUEST["txtmessage"] . "'";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: <" . $_REQUEST["txtfrom"] . ">\r\n";
mail($to, $subject, $message, $headers);
i got that error:
Warning: mail() [function.mail]: SMTP server response: 501 5.5.4

is there any way to solve that?
regards,

Posted: Fri Feb 17, 2006 3:53 am
by Maugrim_The_Reaper
Looks like a Windows error??? Check that your smtp settings in php.ini are correct. What smtp server software are you running?

Since this isn't a PHP error, chances are the code is working as expected - it's just the smtp server you have complaining.

Just an extra tip - filter $_REQUEST to prevent users inserted whatever values they want. If its supposed to be an email address, validate it. If its supposed to be alphanumeric, alphabetic etc. Use the ctype functions to ensure it is. Otherwise an unfiltered, unvalidated mail form will allow spammers to misuse it...