selenium+python smtp邮件

#code:utf-8

import smtplib from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

from email.header import Header

smtpserver = ‘smtp.163.com‘

smtp_user = ‘*******‘

smtp_pass = ‘*******‘

from_addr=‘**********@163.com‘

to_addr= ‘********@qq.com‘

subject = ‘休假申请‘

#message = MIMEMultipart()

message = MIMEText(‘这是今天的休假申请‘,‘plain‘,‘utf-8‘)

message[‘Subject‘] = Header(subject,‘utf-8‘)

message[‘From‘] = from_addr

message[‘To‘] = to_addr

#注释部分为带附件的代码

#message.attach(message_text)

#att1=MIMEText(open(‘test.txt‘,‘rb‘).read(),‘base64‘,‘utf-8‘)

#att1[‘Content-Type‘] = ‘application/octet-stream‘

#att1[‘Content-Disposition‘] = ‘attachment:filename="test.txt"‘

#message.attach(att1)

sm=smtplib.SMTP()

sm.connect(smtpserver,25)

sm.login(smtp_user,smtp_pass)

sm.sendmail(from_addr,to_addr,message.as_string())

sm.quit()

时间: 2024-08-26 22:06:22

selenium+python smtp邮件的相关文章

python smtp邮件

SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式. python的smtplib提供了一种很方便的途径发送电子邮件.它对smtp协议进行了简单的封装. 参考:https://www.cnblogs.com/ysocean/p/7653252.html  https://blog.csdn.net/qq_42543250/article/details/81586663  https:/

Python SMTP邮件模块

SMTP是发送邮件的协议,Python内置对SMTP的支持,可以发送纯文本邮件.HTML邮件以及带附件的邮件. Python对SMTP支持有smtplib和email两个模块,email负责构造邮件,smtplib负责发送邮件. 实例: 1.使用Python发送纯文本格式和html格式的邮件. 1 #!/usr/bin/env python 2 #coding:utf-8 3 4 import smtplib 5 from email.mime.text import MIMEText 6 fr

python SMTP邮件发送

import stmplib from email.mime.text import MIMEText from email.Header import Header mailhost='stmp.qq.com'  #设置服务器 mailuser='[email protected]' #使用时亲测不能用qq.com, maipass='XXXXXXXX'#不是登陆密码,填写授权码,在邮箱中设置smtp服务. sender='[email protected]' #发件人 receiver=['

python发邮件

import smtplib from email.mime.text import MIMEText from email.header import Header # 第三方 SMTP 服务 mail_host="smtp.qq.com" #设置服务器 mail_user="xxxxxx" #用户名 mail_pass="plcfthkdtpoxcabh" #口令QQ需要授权码 sender = '[email protected]' rec

smtp邮件测试

# -*- coding:utf-8 -*- #!/usr/bin/python import sys reload(sys) # reload 才能调用 setdefaultencoding 方法 sys.setdefaultencoding('utf-8') # 设置 'utf-8' import smtplib from email.mime.text import MIMEText from email.header import Header #第三方服务smtp mail_host=

Python——SMTP发送邮件

一.定义 SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式.python的smtplib提供了一种很方便的途径发送电子邮件.它对smtp协议进行了简单的封装. 二.Python创建STMP对象 import smtplib smtpObj = smtplib.SMTP( [host [, port [, local_hostname]]] ) #host: SMTP 服务器主机. 你可

python email 邮件

. . .参考:https://www.runoob.com/python3/python3-smtp.html #encoding=utf-8 ''' Created on 2019年10月11日 @author: sea ''' import smtplib from email.mime.text import MIMEText from email.header import Header def send(From,to,subject,content): ''' send(From,

用python 发送一个smtp邮件

用python写一个简单的邮件,需要发送的邮件内容自定义,可用于监控警告邮件发送. #!/usr/bin/env python import smtplib    //内置smtp库 import string HOST = "smtp.163.com"    //定义用于发送邮件的主机,这里用网易163 SUBJECT = "Test email from Python"    //定义邮件标题 TO = "[email protected]"

python学习笔记(SMTP邮件发送)

想着给框架添加邮件发送功能.所以整理下python下邮件发送功能 首先python是支持邮件的发送.内置smtp库.支持发送纯文本.HTML及添加附件的邮件 之后是邮箱.像163.qq.新浪等邮箱默认关闭SMTP服务,需要我们手动打开 打开后通过发件人邮箱.授权密码 通过发件人的SMTP服务发送 代码如下: 1 #!/usr/bin/env python 2 # -*- coding: utf_8 -*- 3 4 from email.mime.text import MIMEText 5 fr