2011年7月24日 星期日

Send mail example

from smtplib import SMTP
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

to = 'to_address@xxxxxxxxxxxxxxx'
cc = 'cc_address@xxxxxxxxxxxxxxx'
bcc = 'bcc_address@xxxxxxxxxxxxxxx'

msg = MIMEMultipart()
msg['To'] = to
msg['Cc'] = cc
msg['From'] = 'bernhard@xxxxxxxxx'
msg['Subject'] = 'Test'
text = MIMEText('Das ist ein Test')
text.add_header("Content-Disposition", "inline")
msg.attach(text)

s = SMTP('test.smtp.relay')
s.sendmail(msg['From'], [to, cc, bcc], msg.as_string())
s.quit()

沒有留言: