sourceforgeから参照する場合は、電子メールモジュールlibgmail
を使用してメッセージを作成する必要があります。
HTMLメッセージをMIMEドキュメントとして生成し、マルチパートMIMEメッセージの一部として含めます。完全に構築されたマルチパートMIMEがある場合は、 toメソッドlibgmail
を使用して、それを文字列としてコンストラクターに渡します。.as_string()
ドキュメントの例には、同様の要件のコードが含まれています。
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
...
# Record the MIME types of both parts - text/plain and text/html.
# ... text and html are strings with appropriate content.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)