1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/python
import
smtplib
import
string
HOST
=
"smtp.gmail.com"
/
/
发件SMTP主机
tolist
=
[
'12345@qq.com'
,
'56789@qq.com'
,
'18900000000@189.cn'
]
/
/
收件人列表
FROM
=
"xxxx@gmail.com"
/
/
发件人邮箱
SUBJECT
=
"Python Module stmplib test email"
/
/
邮件主题
bodys
=
""" //内容
This is a test mail please delete this mail thank you """
BODY
=
string.join((
"From: %s"
%
FROM,
"To: %s"
%
';'
.join(tolist),
"Subject: %s"
%
SUBJECT,
"",
bodys
),
"\r\n"
)
server
=
smtplib.SMTP()
server.connect(HOST,
"25"
)
server.starttls()
server.login(
"xxxx@gmail.com"
,
"emailpassword"
)
/
/
发件人账户和密码
server.sendmail(FROM,tolist,BODY)
/
/
发送邮件
server.quit()
|
本文转自flyingzf 51CTO博客,原文链接:http://blog.51cto.com/flyingzf/1795451,如需转载请自行联系原作者