Web Hosting Talk







View Full Version : php - mail() function


Lang14
02-19-2005, 05:21 PM
OK, I succesfully sent email through PHP...BUT IT'S SPAM!?!? AHHHH!
How do I fix this? I'm guessing this has something to do with the headers? What headers do i need for it not to be judged as spam?

toweter
02-19-2005, 05:54 PM
what headers are you sending? "X-Mailer: PHP 4.x" (or similar) could be causing the emails to be interpreted as spam..

tanfwc
02-19-2005, 06:36 PM
Check that your mail header has from, to, reply-to. Including X-Mailer should not be a problem because I have that coded in my form too :)

Ultraseeker
02-19-2005, 07:49 PM
Not sure what you mean by "it's spam".
Is your message getting filtered out by your email client? Or do you not see anything in the from name or subject field?

From the PHP docs:

mail("nobody@example.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());

What kind of tests did you run?
Maybe if you let us see the code you use...

Lang14
02-19-2005, 10:23 PM
I use the something from the PHP docs too. I use the following headers.

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";

Ultraseeker
02-19-2005, 11:55 PM
Originally posted by Lang14
OK, I succesfully sent email through PHP...BUT IT'S SPAM!?!?

still not sure what you mean by that...
more details on what happens...

brianoz
02-20-2005, 09:41 AM
He probably means that SpamAssassin is classifying it as spam.

Ultraseeker
02-20-2005, 05:14 PM
You know what they say about what happens when you start "***-uming" things...
Just kidding...

Lang14
02-21-2005, 12:24 PM
Ultraseeker, I used the code you provided from the PHP Docs plus the code I also used so, I could send out HTMl an it worked :D thanks for the help.

Ultraseeker
02-21-2005, 05:04 PM
Glad that worked for you. The PHP docs (HTML help) has a permanent spot on my desktop. I use it all the time...