ex01.py

ex01.py — Python Source, 0Kb

ファイルコンテンツ

#!/usr/bin/env python
# ex01.py
# compose email message
import email.utils
import email.mime.text
#
text = """\
Hello, I am a computer.
-- 
HAL 9000
"""
subject = 'A computer generated email message'
sender = 'foo@example.com'
recipt = 'bar@example.jp'

msg = email.mime.text.MIMEText(text)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipt
msg['Date'] = email.utils.formatdate(localtime=True)

print msg.as_string()