Send email with tables?

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
Sakujou
Forum Newbie
Posts: 2
Joined: Fri Jul 22, 2011 12:25 pm

Send email with tables?

Post by Sakujou »

I'm trying to make an e-mail script that will have a bit of design -

and when I do this code -

Code: Select all

$first_name = "<table border=\"0\" cellpadding=\"5\" width=\"600px\" style=\"font-family:arial;font-size:12px;color:#888;\"><tr><td style=\"border:1px solid #ccc;\">Name</td>" . "<td style=\"border:1px solid #ccc;\">" . $_POST['first_name'] . " ". $_POST['last_name'] . "</td></tr></table>";
making it print in browser is fine - but when I have this send to my email, it's just raw html?

Any suggestions on how to get the table to actually show when it emails as well?

Thanks!
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Send email with tables?

Post by social_experiment »

To send 'html emails' you need the correct headers in your email

Code: Select all

<?php
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'. "\r\n";
?>
Then treat the message of the email like an html document
“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
Sakujou
Forum Newbie
Posts: 2
Joined: Fri Jul 22, 2011 12:25 pm

Re: Send email with tables?

Post by Sakujou »

Thank you - worked perfectly! :)
Post Reply