使用python调用第三方邮箱群发邮件
第三方邮件需要设置授权码这里是
163
邮箱,图上传不了。
设置
=
=
=
>邮箱安全设置
=
=
=
>客户端授权密码
代码部分:
import
smtplib
from
email.mime.text
import
MIMEText as mimetext
from
email.mime.multipart
import
MIMEMultipart
mail_host
=
'smtp.163.com'
sender_user
=
'xxxx_monitor@163.com'
sender_pass
=
'xxxx'
receivers
=
[
'receiver1@163.com'
,
'receiver2@163.cn'
]
message
=
mimetext(
'Python 邮件测试发送'
,
'plain'
,
'utf-8'
)
message[
'From'
]
=
sender_user
message[
'To'
]
=
","
.join(receivers)
subject
=
'Python SMTP 邮件测试'
message[
'Subject'
]
=
subject
smtpobj
=
smtplib.SMTP()
smtpobj.connect(mail_host,
25
)
smtpobj.login(sender_user,sender_pass)
smtpobj.sendmail(sender_user,receivers,message.as_string())
smtpobj.close()