在 Django(使用 python)中,如何构建如下所示的电子邮件:
我需要的是一封开头的电子邮件:
Content-Type: multipart/alternative;
boundary="=_5f8686714d769f9476ce778798b84ff4"
边界是放置纯文本的地方:
--=_5f8686714d769f9476ce778798b84ff4
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
This e-mail is in HTML-format. Click the following link:
http://www.company.nl/enews/7
--=_5f8686714d769f9476ce778798b84ff4
之后我需要一个相关的 Content-Tye:
Content-Type: multipart/related;
boundary="=_e49477d06c604958b9b2bc038628a26f"
边界是放置html的地方
--=_e49477d06c604958b9b2bc038628a26f
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.= w3.org/TR/html4/loose.dtd"> <html style=3D"height: 100%"> <head>/head> <body></body> </html>
--=_e49477d06c604958b9b2bc038628a26f
最终它看起来像这样:
Received: (qmail 6116 invoked by uid 48); 16 Jul 2012 18:00:49 +0200
Date: 16 Jul 2012 18:00:49 +0200
To: my@email.nl
Subject: Something
MIME-Version: 1.0
From: Company <company@company.nl>
Content-Type: multipart/alternative;
boundary="=_5f8686714d769f9476ce778798b84ff4"
Message-ID: <m79ghd.ezdd6g@company.nl>
--=_5f8686714d769f9476ce778798b84ff4
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
This e-mail is in HTML-format. Click the following link:
http://www.company.nl/enews/7
--=_5f8686714d769f9476ce778798b84ff4
Content-Type: multipart/related;
boundary="=_e49477d06c604958b9b2bc038628a26f"
--=_e49477d06c604958b9b2bc038628a26f
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.=
w3.org/TR/html4/loose.dtd">
<html style=3D"height: 100%">
<head>/head>
<body></body>
</html>
--=_e49477d06c604958b9b2bc038628a26f
我用 Django 的 EmailMessage(Alternatives)、python MimeMultipart 尝试了这个,但我无法按照确切的顺序得到它。