$mailcontent formatting (line breaks, text color, bold etc.)

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
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

$mailcontent formatting (line breaks, text color, bold etc.)

Post by edawson003 »

I got a registration page that sends a welcome email and I have the basics down already

Code: Select all

 
$toaddress = $_POST['email'];
   $subject = 'Welcome to mysite.com';
   $mailcontent = 'Welcome '.$fname."\n"
   .'Your username is: '.$_POST['username']. "\n"
   .'To begin, please login and begin setting up your profile'."\n";
   $fromaddress = 'From: newaccounts@mysite.com';
   mail($toaddress, $subject, $mailcontent, $fromaddress);
 
Now, I would like to spruce up the email message a bit (i.e. add bold to certain content elements, colored text, line breaks). How can I pull this off?

I tried this with no success: $mailcontent = 'Welcome '.$fname.'<br>'"\n"

Also, I would like to:
(1) get an email every time someone registers
(2) Add a clickable link back to my site to the mail content
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: $mailcontent formatting (line breaks, text color, bold etc.)

Post by requinix »

You need to send an HTML email. Take a look at the examples on the manual page.
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: $mailcontent formatting (line breaks, text color, bold etc.)

Post by edawson003 »

Perfect! Just what I need. Thanks!
Post Reply