Page 1 of 1

MAIL ()

Posted: Fri Jan 04, 2008 8:22 am
by goldberg
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)

Code: Select all

$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 :?:

Posted: Fri Jan 04, 2008 4:20 pm
by andym01480
Have you tried using \r\n on the headers section as stated in the manual (rather than just \n)?
additional_headers (optional)
String to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n).
You are also in danger of being used by spammers for header injection if you use $_POST['email'] in the headers without making sure it just contains an email address....

Posted: Fri Jan 04, 2008 4:33 pm
by andym01480
Scrub that - it works for me with \n on a Linux PHP installation.

I googled "501 unacceptable mail address" - the server at the gmail end doesn't like your From address.

Why not try the "from" address to be one from your domain and then have a cc: to $e
Answer
Some SMTP servers require that the FROM user be registered with the domain.

Posted: Fri Jan 04, 2008 4:39 pm
by goldberg
Thanks, but thats not it i've tried several diffrent email addresses, and r\n and none of that helps. Thanks tho. :cry:

Posted: Fri Jan 04, 2008 8:00 pm
by feyd
Have you tried Swift Mailer? Even for "simple" stuff, it's quite helpful.

Posted: Fri Jan 04, 2008 9:18 pm
by Jonah Bron
Well, lets narrow this problem down. Start by sending the email without the headers.