import smtplib #python自带 from email.mime.text import MIMEText from email.header import Header class Sendemail(): def sendqqemail(self): emailo=smtplib.SMTP() #SMTP类的实例化对象 emailo.connect('smtp.qq.com',25) #smtp的默认端口号 sendmsg_contents=input('请输入邮件的文字内容:') try: emailo.login('46080****@qq.com','oimmpyaa****bjbe') #oimmpyaa****bjbe是发件人的邮箱的16位授权码,在邮箱的设置-账户-pop3/smtp中发送短信获取。 mg= MIMEText(f'<html><h1>{sendmsg_contents}</h1></html>','html','utf-8')#MIME(Multipurpose Internet Mail Extensions)多用途互联网邮件扩展类型 subject = '666python学习-爱软测同学们使用QQ邮箱给163邮箱发消息' mg['subject'] = Header(subject,'utf-8') mg['from'] = '46080****@qq.com' mg["to"] = 'cherry****@163.com'#mg['subject'],mg['from'],m
编写python的smtplib库发送邮件代码(简洁-原创)
于 2023-03-29 21:32:13 首次发布