emil error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaylin
Forum Commoner
Posts: 68
Joined: Fri Nov 18, 2005 4:44 am

emil error

Post 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,
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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...
Post Reply