Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html email from php not rendering correctly 1

Status
Not open for further replies.
Aug 23, 2004
174
US
Here is the code I am using. The email is being sent but the html isn't rendering when it is recieved.

Code:
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: SummitChem Contact Form <>';
$subject = 'Someone has filled out the contact form on '.SITE_BASE_URL.'/contact-us';
$body = '
Hello,
<ul>
							<li>'.$clean['name'].'</li>
<li>'.$clean['title'].'</li>
<li>'.$clean['email'].'</li>
<li>'.$clean['address'].'</li>
<li>'.$clean['city'].'</li>
<li>'.$clean['state'].'</li>
<li>'.$clean['zip'].'</li>
<li>'.$clean['comments'].'</li>
<li>'.date('F j, Y').'</li>
<li>'.$clean['interest'].'</li>
<li>'.$clean['company'].'</li>
<li>'.$clean['phone'].'</li>
<li>'.$clean['fax'].'</li>
<li>'.$clean['country'].'</li>
</ul>';

mail(ADMIN_EMAIL,$subject,$body,$headers);
 
Here is the email I am getting

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

From: SummitChem Contact Form
Message-Id: <>
Date: Wed,  6 May 2009 10:46:26 -0400 (EDT)

Hello,
<ul>

<li>form data.. </li>

</ul>
 
Does $subject end in a line-end? Or else ADMIN_EMAIL?
Headers and body are separated by a blank line, so if you are seeing the headers as a part of the body, there sould be an extra end-of-line sequence somewhere. If you can see the source of the message (most e-mail clients can show the source), you will see directly where the problem is.


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Might be worthwhile putting the proper HTML constructs in as well e.g. <HTML>....</HTML> etc. Probabby a sound thing to do any how.
Email clients have there own rendering engine so might be more pickey than a browser.
 
From the fine manual: headers should be separated by "\r\n". You do this correctly. However, it says that some buggy mail transfer agents need "\n" only, as they supply the missing "\r" automatically. If I see your mail message and if you have pasted it correctly, the empty line after the Content-type line may suggest that this is the case. So you CAN try supplying "\n" only to see what happens and install a better mail program if that turns out to be the problem.

Jpadie suggested using PHPmailer. It is used in all companies that I worked for as a PHP programmer and it has more options than the mail function itself. It is a good suggestion, although finding the real cause of the problem would not be bad either.


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top