Jump to content

HTML email


TapeGun007

Recommended Posts

$headers = "From: webmaster@xxx.com\r\n" .
        	"Reply-To: webmaster@xxx.com\r\n" .
		"BCC: ".$bcc."\r\n" .
        	"Content-type: text/html\r\n";

 

The email sends fine, it's a form that you input some information into and it collects all the emails of the people that need to be notified.

 

The only issue is that it's not in HTML.  So, if in the email you send a <b> or <p>, it actually shows up in the email instead of actually make the text BOLD or whatever.

 

Am I using the Content-type wrong?

Link to comment
Share on other sites

Using Outlook 2007 and I get HTML emails all the time.

 

No, the email being sent does NOT include the <body> tags and all that... I assumed it was sent... maybe that's the issue.

 

For whatever reason, I just assumed that was already there and oddly enough, didn't think of it. duh >.<

Link to comment
Share on other sites

Might wanna try the stuff below.

<?php
//change this to your email.
    $to = "fatmonkeys@lalalalala.com";
    $from = "evenfattermonkeys@lalalalalalala.com";
    $subject = "HTML email from fatmonkeys";

    //begin of HTML message
$message = <<<fatmonkeys
<html>
  <body bgcolor="#DCEEFC">
    
  </body>
</html>
fatmonkeys;
   //end message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

    //send the email.
    mail($to, $subject, $message, $headers);

    echo "Message from fat monkeys has been sent";

   ?>

Link to comment
Share on other sites

Actually... what you suggested didn't work, but I now know WHY.  I'm using a Javascript text editor, I use it in several places on my website.  For some reason, the form that submits the text for the created email is stripping all the HTML tags.

 

For example, I use the text editor to update the front page news.  So if someone highlights a word and makes it bold on the screen, it writes that information to the db as HTML code.  But for some reason on this email form, it is removing all the HTML code.  Not sure why, it's the exact same text editor... I'll have to review my other code to see what I did there I guess.

Link to comment
Share on other sites

yeah or ditch the editor, the script i gave works as is.

 

I wish it were that easy.  The people writing the emails are not HTML knowledgeable.  They don't know what <b> does.  So I have a WYSIWYG editor that works well on every other part of the site.  Like I have a calendar, and if they put an event on there in bold, it simply shows up as bold on the calendar.  They aren't having to code it.

 

In this case, they need to be able to create bold items, bulleted items and such.  I wanted to make the email form very user (and HTML ignorant) friendly.

Link to comment
Share on other sites

Well in that case, you could of course allow them to use the html code, But automatically add <html><body> to the beginning and </body></html> to the end for there input.

That way they can do as they like in the body and not fack up your html email. Do realise that some html tags wont work very well in email.

 

If you have questions or need help let me know. Like to see what you did in the end ::)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.