标签:use smtp == 邮箱 word input login int bsp
yagmail
import yagmail def login(user, pwd,host ,smtp_ssl): user = user # 邮箱账号 pwd = pwd # 授权码,不是邮箱密码 mail = yagmail.SMTP(user=user, password=pwd, host=‘smtp.163.com‘,# 服务器就 smtp.*.com smtp_ssl=smtp_ssl # 安全协议,非必须 ) def send_msd(to, cc, subject, contents, attachments): mail.send( to=[to,], # 多人写成列表[] cc=[cc,], # 抄送 subject=subject, # 邮件标题 contents=contents, # 邮件正文 attachments=attachments) # 多个附件写成列表[] print(‘发送成功‘) if __name__ == ‘__main__‘: user = input(‘帐号:‘) pwd = input(‘授权码:‘) host = input(‘服务器:‘) smtp_ssl = input(‘是否启用安全服务:‘) login(user, pwd, host, smtp_ssl) to = input(‘请输入发送对象‘) cc = input(‘请输入抄送对象‘) subject = input(‘请输入邮件主题‘) contents = input(‘请输入邮件内容‘) attachments = input(‘请输入附件路径‘) send_msg(to, cc, subject, contents, attachments)
标签:use smtp == 邮箱 word input login int bsp
原文地址:https://www.cnblogs.com/ray-mmss/p/10305952.html