Python 邮件发送消息
# 代码
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:supery import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr class BaseMessage(object):
def send(self, subject, body, to, name):
raise NotImplementedError('未实现send方法') class Email(BaseMessage):
def __init__(self):
self.email='1xx@163.com'
self.user = 'Supery'
self.pwd = 'xxx' def send(self, subject, body, to, name):
msg = MIMEText(body,'plain','utf-8')
msg['Form'] = formataddr([self.user,self.email])
msg['To'] = formataddr([name,to])
msg['Subject'] = subject server = smtplib.SMTP('smtp.163.com',25)
server.login(self.email,self.pwd)
server.sendmail(self.email,[to,],msg.as_string())
server.quit()
# 使用
Email('90xxx9@qq.com','liu','你别走了','xxx太多了')
Python 邮件发送消息的更多相关文章
- centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本)
centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本) ##################### sendmail.py begin ######## ...
- Python 邮件发送
python发送各类邮件的主要方法 python中email模块使得处理邮件变得比较简单,今天着重学习了一下发送邮件的具体做法,这里写写自己的的心得,也请高手给些指点. 一.相关模块介绍 ...
- Python邮件发送脚本(Linux,Windows)通用
脚本 #!/usr/bin/python #-*- coding:utf-8 -*- #Python Mail for chenglee #if fileformat=dos, update file ...
- python邮件发送
'''qq邮件与其他邮件有所不同,下以我的qq邮件为例(切勿转载):''' import osimport smtplibfrom email.mime.text import MIMEText # ...
- python邮件发送脚本
转自:http://phinecos.cnblogs.com/ #!/usr/bin/python #coding=utf-8 #@author:dengyike #@date:2010-09-28 ...
- Python邮件发送源码
-- coding:utf-8 -- i = 0 while i < 10: #发送十次 import smtplib from email.mime.text import MIMEText ...
- python邮件发送自动化测试报告
话不多说直接贴代码 # encoding: utf-8import smtplib #发送邮件模块from email.mime.text import MIMEText #邮件内容from emai ...
- python邮件发送:普通文本、html、添加附件
# -*- coding: utf-8 -*- # @Time : 2019/9/19 13:46 # @Author : HuangWenjun # @Email : 350920551@qq.co ...
- python 邮件发送 脚本
import smtplib from email.header import Header from email.mime.text import MIMEText from_addr = 'XXX ...
随机推荐
- JavaScript身份证号码有效性验证
最近需要对身份证合法性进行验证,实名验证是不指望了,不过原来的验证规则太过简单,只是简单的验证了身份证长度,现在业务需要加强下身份证验证规则,网上找到了不少资料,不过都不合偶的心意,无奈只好直接写一个 ...
- 背景建模技术(五):视频捕获(VideoCapture)模块
本次对“视频捕获(VideoCapture)模块”做出分析,给出源代码和对应的程序流程框架. 视频捕获模块的主要功能是设置视频或相机参数,并读取设置配置参数,最后进入帧处理模块的process进程,该 ...
- UIView的autoresizingMask属性研究
在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高. 1 2 3 4 5 6 7 8 9 enum ...
- STL中的map和unordered_map
STL中的map和unordered_map map 头文件:#include 原理:std::map的内部实现了一颗红黑树,有对其键值进行排序的功能,所以map是一个有序的容器,map中的每一个元素 ...
- mysql的select的五子句
转: http://www.cnblogs.com/billyu/p/5033167.html http://www.cnblogs.com/xiadong90-2015/p/4222965.html ...
- POJ 2429 long long 质因数分解
GCD & LCM Inverse Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16206 Accepted: ...
- pc扫码支付
https://www.cnblogs.com/shengyu-kmust/p/5228261.html https://pay.weixin.qq.com/wiki/doc/api/native.p ...
- spring boot 在IDEA控制台中打印彩色日志
只需要在application.properties中加入 spring.output.ansi.enabled=ALWAYS 即可
- 小米路由器设置DMZ主机 并在外网访问
一.前提条件: 1.小米路由器 2.拥有公网IP的网络 二.步骤: 1.登陆小米路由器管理界面 miwifi.com 2.高级设置=>端口转发 页面底部的DMZ选项开启,然后选择需要映射到外 ...
- C11简洁之道:函数绑定
1. 可调用对象 在C++中,有“可调用对象”这么个概念,那么什么是调用对象呢?有哪些情况?我们来看看: 函数指针: 具有operator()成员函数的类对象(仿函数): 可以被转换为函数指针的类对 ...