Forum Moderators: coopster

Message Too Old, No Replies

mail() is not setting up headers correctly

         

erikcw

2:40 am on Jun 10, 2004 (gmt 0)

10+ Year Member



Hi All,

mail() is not placing the headers data in the headers section of the message, but instead in the body.

I took the code straight out of the php.net manual. What do I need to do to signify that this is HTML email to the client yet not have header codes showing up in the body? (Also Eudora is not reading the From header, when I click reply the To: is blank...)


To: erik@domain.com
Subject: Erik, your Password Request

Content-type: text/html; charset=iso-8859-1
From: Management <support@domain.com>

Dear Erik,

Per your request, we have reset your account password.

E-mail: erik@domain.com
Password: FkwCSg

You may now change your password after you have logged in by clicking the 'Edit Preferences' link. Please keep in mind that the account management center is accessible 24 hours a day, 7 days a week. If you have any questions regarding this email or your account, please reply to this email. Thanks again for your continued support.

Sincerely,

Management


/* recipients */
$to = $_rowUser[1];

/* subject */
$subject = $_rowUser[3] . ", your Password Request";

/* message */
$message = "
<html>
<head>
<title>" . $subject . "</title>
</head>
<body>
<p>
Dear " . $_rowUser[3] .",
<p>
Per your request, we have reset your account password.
<p>
E-mail: <b>" . $_rowUser[1] . "</b>
<br>
Password: <b>" . $rnd_id . "</b><p>
You may now change your password after you have logged in by clicking the 'Edit Preferences' link. Please keep in mind that the account management center is accessible 24 hours a day, 7 days a week. If you have any questions regarding this email or your account, please reply to this email. Thanks again for your continued support.
<p>
Sincerely,
<p>
Management
</body>
</html>
";

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Management <support@domain.com>\r\n";

/* additional headers */
// $headers .= "To: " . $_rowUser[3] . " <" . $_rowUser[1] .">\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);

WhosAWhata

5:08 am on Jun 10, 2004 (gmt 0)

10+ Year Member



the mail() function is very picky
take a look at this thread from a few months ago [webmasterworld.com...] .
jatar_k's code worked for me

$to = "Some Person <email@domain.com>";

$subject = "Mail";

$message = "<html><center><h1>HTML</h1></center></html>";

$from = "From: $fromemail\n";
$from .= "X-Sender: $fromemail\n";
$from .= "X-mailer: PHP\n";
$from .= "X-Priority: 3\n";
$from .= "Return-Path: $fromemail\n";
$from .= "Reply-To: $fromemail\n";
$from .= "Content-type: text/html\n";

mail($to,$subject,$message,$from);

johnerazo

5:16 am on Jun 10, 2004 (gmt 0)

10+ Year Member



Try removing the extra '\r\n'

From....

$headers .= "From: Management <support@domain.com>\r\n";

to...

$headers .= "From: Management <support@domain.com>";