HTML email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
luthar28
Forum Newbie
Posts: 2
Joined: Sun Jan 02, 2011 8:19 am

HTML email

Post by luthar28 »

Hello, I am trying to send an HTML email (even a multipart would be fine...both text and html).

All my clients read it properly (as html) but some others it's is coming with non-parsed html code (<html><body><h1>This is an email</h1></body></html>). I have spent hours on this and still can't seem to solve the problem.

This is my code, can anyone see anything wrong with it?

Code: Select all

$message = "<html><body><h3>This is your message, ".$FirstName." ".$LastName."</h3>\n ";
$message.= "You have been assigned a Society Number.  Please do not lose this number as you will need it to login.<br> ";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

$headers = 'From: info@prixaurorawards.ca' . "\r\n" .
    'Reply-To: info@prixaurorawards.ca' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Send
mail($Email, 'Registration Confirmation', $message, $headers);
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: HTML email

Post by anantha »

i could not see a closing body and html tag?
luthar28
Forum Newbie
Posts: 2
Joined: Sun Jan 02, 2011 8:19 am

Re: HTML email

Post by luthar28 »

anantha wrote:i could not see a closing body and html tag?
Yeah, good catch. Just tried it. Same result though.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: HTML email

Post by social_experiment »

luthar28 wrote:All my clients read it properly (as html) but some others it's is coming with non-parsed html code (<html><body><h1>This is an email</h1></body></html>)
Slight confusion here, you say all your clients reads it properly, yet in the next line you say that others doesn't?
Also, you are using this line of code to wrap the message. Maybe you are cutting of the tags at the end.

Code: Select all

<?php $message = wordwrap($message, 70); ?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply