Email Tutorials - Herong's Tutorial Examples - v1.04, by Herong Yang
Content-Type: text/html - HTML Content
This section provides an email message example with 'Content-Type: text/html' header for HTML formatted message content.
What Is "Content-Type: text/html" Email Header? "Content-Type: text/html" specifies that the email message content is an HTML formatted document. It tells the email client tool to render the content into a formatted Web page.
"text/html" and other "Content-Type" values are defined in "RFC1341 - MIME (Multipurpose Internet Mail Extensions): Mechanisms for Specifying and Describing the Format of Internet Message Bodies" at datatracker.ietf.org/doc/html/rfc1341.
If "Content-Type" header is not provided, the default of "Content-Type: text/plain" is assumed. In this case, the message content contains text without any formatting.
The default of "Content-Type: text/plain" is good enough, if you just want to send a short greeting message to your friend.
If you want to send nice looking wedding invitation, you can create the invitation as an HTML document and send it with the "Content-Type: text/html" header. Here is a simple example:
Return-Path: <chloe@herongyang.com> Delivered-To: herong@herongyang.com Received: from 127.0.0.1 (localhost [127.0.0.1]) by mail.herongyang.com (Postfix) with ESMTP id 5EABD266002B for <herong>; 15 Nov 2023 06:19:34 -0500 (EST) Message-Id: <20231113111946.5EABD266002B@mail.herongyang.com> Date: 15 Nov 2023 06:19:34 -0500 (EST) From: chloe@herongyang.com Content-Type: text/html <p style="text-align: center"> <span style="font-family: 'Dancing Script'; font-size: 4em">Chloe <span style="font-size: 0.5em">&</span> Oliver</span><br/> <br/> <span style="font-family: sans-serif; font-size: 1em"> INVITE YOU TO CELEBRATE THEIR WEDDING DAY<br/> <br/> <span style="font-size: 2em">JULY 7, 2027</span></span> <p>
When an email client tool receives a message with "Content-Type: text/html", it will render the message content like a Web page based on embedded HTML tags. Text paragraphs can be styled. References can become clickable links. Data elements can be organized into tables. Images and videos can be embedded directly.
Table of Contents
Postfix - Mail Transport Agent (MTA)
SSL/TLS Secure Connections with Postfix Server
Dovecot - IMAP and POP3 Server
SSL/TLS Secure Connections with Dovecot Server
Email Client Tools - Mail User Agents (MUA)
Mozilla Thunderbird - Mail User Agents (MUA)
PHPMailer - PHP Package for Sending Emails
►Email Message Format and Headers
Email Message Format and Example
What Are Email Message Headers
►Content-Type: text/html - HTML Content
Content-Type: multipart/alternative; boundary="..."
Content-Type: multipart/mixed; boundary="..."
Content-Transfer-Encoding: 8bit - Non-ASCII Content
Content-Transfer-Encoding: base64 - Base64 Encoded Content
Content-Transfer-Encoding: quoted-printable - 7-Bit Encoding
Subject: =?...?= - 7-Bit Encoding
From: ... - Email "From" Address
To: ... - Email "To" Addresses