Email html format text format

tylermakin / Multipart MIME Email.md

This is a guide on how to send a properly formatted multipart email. Multipart email strings are MIME encoded, raw text email templates. This method of structuring an email allows for multiple versions of the same email to support different email clients.

// Example Multipart Email: From: sender@example.com To: recipient@example.com Subject: Multipart Email Example Content-Type: multipart/alternative; boundary="boundary-string" --your-boundary Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Plain text email goes here! This is the fallback if email client does not support HTML --boundary-string Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 

This is the HTML Section!

This is what displays in most modern email clients

--boundary-string--

Different Content-Type Sections

Multipart email strings are composed of sections for each Content-Type version of the email you wish to use. By sending differently formatted versions, you can ensure your recipients are able to see whatever message you are sending, optimized for their email clients’ capabilities.

Content-Type Description
text/html This allows the use of HTML ( , , ,

, etc.)

text/plain For sending an email as only text without formatting
text/watch-html Limited HTML support, similar in effect to rich text formatting

Example use cases of different Content-Type :

  • Send beautifully formatted HTML emails using text/html for an experience similar to that of a web browser
  • For older email clients or recipients who have HTML specifically turned off, use text/plain
  • Apple Watch does not display full HTML emails, so you may send an email without images or styles using text/watch-html
  • The email client on Apple Watch is able to support a format similar to rich-text, albeit with some quirks

The plain text format is a means to send an unformatted copy of an email, without images or styles, that will be readable by everyone.

Although HTML makes emails beautiful, plain text makes them functional. In addition to helping prevent your emails from getting caught in the spam filter, a plain text version of your email will allow everyone to see your message, regardless of email client. or settings.

// Plain Text Example From: sender@example.com To: recipient@example.com Subject: Multipart Email Example Content-Type: multipart/alternative; boundary="boundary-string" --your-boundary Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Plain text formatted content --boundary-string-- 

HTML formatting allows for the use of web languages (HTML and CSS) to style emails, display images, etc. It is important to always include a plain text version of the email when using HTML because some email clients do not support HTML emails, and some recipients prefer plain text format.

HTML format allow for the use of tags such as

Title

and styles such as

Touch of Gray

in your emaill. This format also allows for the use of remote images via links .

// Example Multipart Email: From: sender@example.com To: recipient@example.com Subject: Multipart Email Example Content-Type: multipart/alternative; boundary="boundary-string" --your-boundary Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Plain text formatted content --boundary-string Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline HTML formatted content --boundary-string-- 

You can send emails specifically formatted to the text/watch-html format to allow for Apple Watch users to view your emails on their devices.

// Apple Watch Example From: sender@example.com To: recipient@example.com Subject: Multipart Email Example Content-Type: multipart/alternative; boundary="boundary-string" --your-boundary Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Plain text formatted content --boundary-string Content-Type: text/watch-html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Apple Watch formatted content --boundary-string-- 

The Apple Watch email client has limited support for HTML and is similar in ability to rich text format (see table). Although images are possible in this format, they are quirky and may not display properly.

You may test your email by sending it via a service such as the free PutsMail tool and seeing how it appears in your inbox. Services such as this allow the testing of emails without the need for an email API (Mandrill, Mailgun, Amazon SES, etc.) email service provider, or your own email server.

Although PutsMail does not allow you to send an entire multipart email as a MIME string (all of the examples in this guide), you can send each section (HTML, plain text, watch) individually by copy/pasting the code for each type individually without the headers.

Источник

Читайте также:  Открыть файл json javascript
Оцените статью