HTML in emails

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
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

HTML in emails

Post by Wldrumstcs »

Ok, I have an email that is being sent to users. How do I include HTML in it because right now it is actually displaying the html. My code is as follows:

Code: Select all

$subject = "Login Info.";
$emailbody = "
Here is your login information:

USERNAME:  $_POST[username]
PASSWORD:  alsdlf;jas;ldjf;lakshdfg

Your old password was reset to this default password.  To change your password you must <a href='http://www.----.com'>Login</a>, then click on 'Update Your Profile.'

If you have any questions whatsoever, feel free to email the department head <a href='mailto:--@-----.com'>-- -----</a> or the <a href='mailto:---@-----.com>webmaster</a>.
-------------------------------------------
This is an automatically generated email.  Please DO NOT respond.";
mail($email_result, $subject, $emailbody, "From: Webmaster");
Thanks!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You will have to research e-mail headers, and create an e-mail header which indicates the content-type is html. I have never done it so I can't tell you more than that.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

out of the manual***

Code: Select all

/* To send HTML mail, you can set the Content-type header. */ 
$headers  = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

/* additional headers */ 
$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n"; //if you dont set these headers (to and from, most spam assasins will mark them as spam!!
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n"; 

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