PDA

View Full Version : PHP, mail function and email headers...


PhilW
10-17-2007, 08:24 AM
Ok, new problem I discovered after moving hosts.... the php mail funtion...

In my form I have, I'm specifying header info, such as:

$headers="From: $from\r\n";
$headers.="Return-Path: <email removed for spam reasons>\r\n";
$headers.="X-Mailer: New Member App PHP Script\r\n";
$headers.="Cc: $cc\r\n";
$headers.="MIME-Version: 1.0\r\n";
$headers.="Content-type: text/html; charset=iso-8859-1\r\n";

Then build the message content in normal HTML.

Parse to to the mailer as
mail($headers,$to,$subject,$message);

Now, when I receive the mail message to my gmail account, it looks like:

X-Mailer: New Member App PHP Script

Cc: <user provided email address>

MIME-Version: 1.0

Content-type: text/html; charset=iso-8859-1

Message-Id: <20071017130823.9036A2EF52@web4.steadfast.net>
Date: Wed, 17 Oct 2007 08:08:23 -0500 (CDT)



<html>
<body font-type='arial' font-size=10pt>
<h3>New Dog faction Guild Member Application</h3>
<hr>
<p>

It's like it's taking the info I specify as header now and placing it all as text. Anyone have any ideas? This works as intended on my last host. Is there something the PHP mailer function is doing?

Justec
10-17-2007, 03:17 PM
bool mail ( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]] )

http://us.php.net/function.mail

PhilW
10-17-2007, 09:09 PM
I actually did have the "to" first, but was messing around with it. Still the same result.

Like I said, was fine when sent with the other host.

EDIT:

I removed the \r prior to the \n, and it cleaned the header up enough to seemingly fix it.

Justec
10-18-2007, 09:55 PM
Its always the smallest things! Glad to hear you got it working.

amanda
09-07-2008, 11:58 PM
The mail() function allows you to send emails directly from a script.

This function returns TRUE if the email was successfully accepted for delivery, otherwise it returns FALSE.

mail(to,subject,message,headers,parameters)