Python⾃动发邮件,只需20⾏代码!
今⽇分享
Python⾃动发邮件
import smtplib
from email import (header)
from email.mime import (text, application, multipart)
import time
宠物出国今⽇分享
Python⾃动发邮件
import smtplib
from email import (header)
from email.mime import (text, application, multipart)
import time突围演员表
def sender_mail():
smt_p = smtplib.SMTP()
t(host='smtp.qq', port=25)
sender, password = '113097485@qq', "**************"
smt_p.login(sender, password)
保卫萝卜2攻略39receiver_addresses, count_num = [
'guozhennianhua@163', 'xiaoxiazi99@163'], 1
for email_address in receiver_addresses:
东华帝君try:
msg = multipart.MIMEMultipart()
房产证办理msg['From'] = "zhenguo"
msg['To'] = email_address
清汤面msg['subject'] = header.Header('这是邮件主题通知', 'utf-8')
msg.attach(text.MIMEText(
'这是⼀封测试邮件,请勿回复本邮件~', 'plain', 'utf-8'))
smt_p.sendmail(sender, email_address, msg.as_string())
time.sleep(10)
print('第%d次发送给%s' % (count_num, email_address))
count_num = count_num + 1
except Exception as e:
print('第%d次给%s发送邮件异常' % (count_num, email_address))
continue
smt_p.quit()
sender_mail()
注意:
发送邮箱是qq邮箱,所以要在qq邮箱中设置开启SMTP服务,设置完成时会⽣成⼀个授权码,将这个授权码赋值给⽂中的password变量。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论