goldberg Posted January 4, 2008 Share Posted January 4, 2008 Hi I am having some problems using the mail function with a form. I am getting this error message: Warning: mail() [function.mail]: SMTP server response: 501 unacceptable mail address in ... Here is my code($msg is defined elsewhere) $e =$_POST[email]; $headers="From: ".$e."\n" . "Content-Type: text/plain; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail("theiblis11@gmail.com","funding questionare",$msg,$headers); and also I know the $e var is working because I echo it and it looks fine. I don't kow whats wrong please help! Thanks - Goldberg ??? Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/ Share on other sites More sharing options...
simcoweb Posted January 4, 2008 Share Posted January 4, 2008 Try changing this: $e = $_POST; to this: $e = $_POST['email']; Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430541 Share on other sites More sharing options...
goldberg Posted January 4, 2008 Author Share Posted January 4, 2008 Thanks, but that did not change anything... still getting the same error. Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430547 Share on other sites More sharing options...
cooldude832 Posted January 4, 2008 Share Posted January 4, 2008 what is the ... break your mail tag into two lines <?php $e =$_POST['emai'l]; $headers="From: ".$e."\n" . "Content-Type: text/plain; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail("theiblis11@gmail.com", "funding questionare",$msg,$headers); ?> tell me if its the first line or second line erroring Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430551 Share on other sites More sharing options...
goldberg Posted January 4, 2008 Author Share Posted January 4, 2008 The problem is in the second line when I break it up, I am almost postive that the problem is with $headers. Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430556 Share on other sites More sharing options...
duclet Posted January 4, 2008 Share Posted January 4, 2008 Change \n to \r\n Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430559 Share on other sites More sharing options...
goldberg Posted January 4, 2008 Author Share Posted January 4, 2008 Thanks but that didn't work either. Here is what I have now $e =$_POST['email']; $headers="From: ".$e."\r\n" . "Content-Type: text/plain; charset=$charset; format=flowed\r\n" . "MIME-Version: 1.0\r\n" . "Content-Transfer-Encoding: 8bit\r\n" . "X-Mailer: PHP\r\n"; if ($short_ip != "203.144" && $short_ip != "212.138") mail("theiblis11@gmail.com", "funding questionare",$msg,$headers); Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430569 Share on other sites More sharing options...
duclet Posted January 4, 2008 Share Posted January 4, 2008 First, check to make sure that you are getting the correct value for $e and $charset by echoing them. If they are correct, then I don't think this is a PHP problem but I just run your code and it worked on my server. Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430573 Share on other sites More sharing options...
goldberg Posted January 4, 2008 Author Share Posted January 4, 2008 Thank you, I echoed them both and they work Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-430577 Share on other sites More sharing options...
goldberg Posted January 7, 2008 Author Share Posted January 7, 2008 Turns out that the space between From: and the " was screwing the whole thing up. It's working fine now like this $headers = "From:".$e."\r\n"; if ( 1==1) mail("hgarner@bvfr.com","funding questionare",$msg,$headers); thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/84505-solved-mail/#findComment-432948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.