By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Sending a HTML e-mail message

P: 142
Hi, I tried to get a script or something to send my e-mial in HTML format becasuse I want to add tables to line up certain text.

How do I get the e-mail to go from plain text to HTML?


$con = mysql_connect("******","******","****");
if (!$con)
die('Could not connect: ' . mysql_error());
}mysql_select_db("total", $con);$result = mysql_query("SELECT * FROM email");while($row = mysql_fetch_array($result))
$to = "$row[a1]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "";
$headers = "From: $from";
echo "Mail Sent.";


Dec 11 '07 #1
Share this Question
Share on Google+
1 Reply

P: 41
You'll have to add the following to your headers variable:
Expand|Select|Wrap|Line Numbers
  1. $headers  = 'MIME-Version: 1.0' . "\r\n";
  2. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Then just build your html in your message variable like so:
Expand|Select|Wrap|Line Numbers
  1. $message = '<html><head><title>Some Title Here</title></head>';
  2. $message .= '<body><p>So and so sent you this url';
  3. $message .= '<a href="" title="URL Title">Url Title</a><br/>';
  4. $message .= 'And a message : <br/>';
  5. $message .= $mailMessage.'</p></body></html>';
Hope this helps. Let me know.
Dec 11 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.