import smtplib
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
toaddr = ['[email protected]', '[email protected]', '[email protected]']
me = 'From: My Name'
you = 'To: ' + ', '.join(toaddr)
server = 'smtp.gmail.com'
port = 25
user_name = '[email protected]'
user_passwd = 'password'
msg = MIMEMultipart('mixed')
msg['Subject'] = 'Заголовок письма'
msg['From'] = me
msg['To'] = ', '.join(toaddr[0:2])
msg['cc'] = ', '.join([ toaddr[2] ])
part1 = MIMEText('Содержимое письма', 'plain')
part2 = MIMEText('Содержимое приложенного файла', 'text/html;name="tasks.htm"', 'utf-8')
msg.attach(part1)
msg.attach(part2)
s = smtplib.SMTP(server, port)
s.starttls()
s.login(user_name, user_passwd)
s.sendmail(me, toaddr, msg.as_string())
s.quit()