ex01.py

ex01.py — Python Source, 0Kb

ファイルコンテンツ

#!/usr/bin/env python
# ex01.py
# compose email message
# imports for python 2.4 ... see comments for python 2.5
import email.Utils          # email.utils
import email.MIMEText       # 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.MIMEText.MIMEText(text)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipt
msg['Date'] = email.Utils.formatdate(localtime=True)

print msg.as_string()