本文实例为大家分享了python3.5 email发送邮件的具体代码,供大家参考,具体内容如下
直接套用代码即可
from email.mime.text import MIMEText from email.mime.image import MIMEImage from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email import encoders import smtplib import time def send_mail(subject): email_host = '' # 服务器地址 sender = '' # 发件人 password = '' # 密码,如果是授权码就填授权码 receiver = '' # 收件人 msg = MIMEMultipart() msg['Subject'] = subject # 标题 msg['From'] = '' # 发件人昵称 msg['To'] = '' # 收件人昵称 signature = ''' \n\t this is auto test report! \n\t you don't need to follow ''' # text = MIMEText(signature, 'plain') # 签名 # msg.attach(text) # 正文-图片 只能通过html格式来放图片,所以要注释25,26行 mail_msg = ''' <p>\n\t this is auto test report!</p> <p>\n\t you don't need to follow</p> <p><a href="http://blog.csdn.net/wjoxoxoxxx" rel="external nofollow" >我的博客:</a></p> <p>截图如下:</p> <p><img src="/UploadFiles/2021-04-08/cid:image1">以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。