Jump to content

How can I set up pretty/styled emails?


floridaflatlander
 Share

Recommended Posts

How can I set up pretty/styled emails and mailing list?

 

I can use php's mail() and I use it all the time but I can't style the email article or add pics.  Every time I add an h1 tag for a test I get <h1> in the email not the style text.

 

Does anyone have links to tell me how to do this?
Is it worth the hassle?
Would it just be easier just to use someone like constantcontact dot com

 

Thanks

Link to comment
Share on other sites

In order for the message to be parsed as HTML, you need to set it's Content-type header to text/html. You can do this using the fourth parameter of the mail function.

 

As a rule of thumb, you should also send a plain-text copy of your emails if you send a HTML message. That way people who cannot or choose not to receive HTML based email still see a readable message rather than a bunch of HTML garbage. In order to do this though you need to generate a proper MIME message with the correct headers and body structure. If you ever want to add attachments you'll need MIME as well.

 

It's better to just use a mailing library rather than try and handle all this stuff (and more) yourself. A couple popular libraries for PHP are Swiftmailer and PHPMailer. Check those out, see which one you prefer and use it. Or as you mentioned, just use a third-party to do your mailing, which may open up more features such as tracking.

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.