forked from ashen-zhao/autobuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmail.py
39 lines (33 loc) · 1.01 KB
/
sendmail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
#coding: utf-8
# sendEmail title content
import sys
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = 'xxxxx'
receiver = '[email protected]'
smtpserver = 'smtp.exmail.qq.com'
username = sender
password = 'xxxxx'
def send_mail(title, content):
try:
msg = MIMEText(content,'plain','utf-8')
if not isinstance(title,unicode):
title = unicode(title, 'utf-8')
msg['Subject'] = title
msg['From'] = sender
msg['To'] = receiver
msg["Accept-Language"]="zh-CN"
msg["Accept-Charset"]="ISO-8859-1,utf-8"
msg['CC'] = '[email protected];[email protected];apple_developer@uubee;'
smtp = smtplib.SMTP_SSL(smtpserver,465)
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print "邮件发送成功!"
return True
except Exception, e:
print str(e)
print "邮件发送失败!"
return False