makeMIME demo


Skip navigation.

Site search

Site navigation

Version capabilities

Version 1 could create simple emails with HTML/text alternatives and attachments. Version 2 introduced support for embedded content like images in HTML email bodies, as well as giving the correct content types for attachments and embeds. This also made it possible to attach email messages, by using an attached file type (typically using the eml file extension) that is picked up as the message/rfc822 content type.

Version 3 now complies with RFC2822's restrictions on body line length and line breaks, gives the correct content-transfer-encoding to allow it to correctly handle non-ascii content, uses quoted-printable where available (PHP versions prior to 5.3.0 will need the php_imap extension installed to enable quoted-printable transfer encoding), uses flowed format where appropriate, allows text and HTML bodies to have their charset specified to allow better support for unicode, and only gives minimal multiparts. The last of these means that, for example, multipart/mixed is only included if there are actually some attachments. This should avoid confusing naive email clients, and prevent them showing an attachment icon for the email, unless there are actually some attachments.

To download the script(s), and see the script license, use the links on the navigation panel at the top of this page.

Sample output

This script can work on its own - attachments or embeds will either need mime_content_type from the mime magic extension, or my giveMimeType library. For automatic production of a plain text body from an HTML body, my html2text library is recommended. Both of these libraries are included here for demonstration purposes. This is initialised using:


The makeMIME script automatically detects that the other scripts have been provided and uses html2text to produce the plain text body, if it has been left blank.

Tailor the demo

Body types
Attached/embedded files
Optional headers

Email output

This is a text output of the email. This script can send the email too, but I have set it in debug mode:

To: "Jessica Marple" <>,
Subject: Time to get a new bike
From: "Fran Roberts" <>
Cc:, "Columbo" <>
X-Priority: 4
X-Mailer: makeMIME v3.0 in PHP by MTWJ
Mime-Version: 1.0
X-Custom: I made this up
Content-Type: multipart/mixed; boundary="MTWJ_mixed_bound_0A"

This is a MIME email - please upgrade to a MIME compatible email client

Content-Type: multipart/alternative; boundary="MTWJ_alt_bound_0A"

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

My email

Hi all,

[LINK:] HowToCreate
[LINK:] Cavinguk
[LINK:] UKCaves

I have been meaning to tell you *I, yes, me* have been thinking about
buying A NEW BIKE!!!

Any ideas of what design I need?



PS, I am using Fran's email today

Content-Type: multipart/related; boundary="MTWJ_rel_bound_0A"

Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

=09=09<title>My email</title>
=09<body text=3D"#000000" bgcolor=3D"#33ccff" link=3D"#000099" vlink=3D"#99=
0099" alink=3D"#000099" background=3D"cid:MTWJ_cnid_0A_1@makeMIMEembed">
=09=09<h4>Hi all,</h4>
=09=09<table cellpadding=3D"2" cellspacing=3D"2" border=3D"1" width=3D"40" =
=09=09=09=09<td valign=3D"top">
=09=09=09=09=09<a href=3D"">HowToCreate</a><br=
=09=09=09=09=09<a href=3D"">Cavinguk</a><br>
=09=09=09=09=09<a href=3D"">UKCaves</a>
=09=09=09I have been meaning to tell you <b>I, yes, me</b> have been thinki=
ng about
=09=09=09buying<font size=3D"+1" color=3D"#ff6600"> A NEW BIKE!!!</font>
=09=09=09Any ideas of what design I need?
=09=09<hr width=3D"100%" size=3D"1">
=09=09=09<font color=3D"#666666">PS, I am using Fran's email today</font>

Content-Type: image/png
Content-Disposition: inline; filename="hatch.png"
Content-Transfer-Encoding: base64
Content-ID: <MTWJ_cnid_0A_1@makeMIMEembed>




Content-Type: image/gif
Content-Disposition: attachment; filename="tinyblue.gif"
Content-Transfer-Encoding: base64


Content-Type: image/gif
Content-Disposition: attachment; filename="tinyred.gif"
Content-Transfer-Encoding: base64


This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.