python 发送邮件模块

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
import  smtplib
import  string
 
HOST = "smtp.gmail.com"  / / 发件SMTP主机
tolist = [ '12345@qq.com' , '56789@qq.com' , '18900000000@189.cn' / / 收件人列表
FROM = "xxxx@gmail.com"  / / 发件人邮箱
SUBJECT = "Python Module stmplib test email"  / / 邮件主题
bodys = """ //内容
This is a test mail please delete this mail thank you """
BODY  =  string.join((
         "From: %s"  %  FROM,
         "To: %s"  %  ';' .join(tolist),
         "Subject: %s"  %  SUBJECT,
         "",
         bodys
         ), "\r\n" )
 
server = smtplib.SMTP()
server.connect(HOST, "25" )
server.starttls()
server.login( "xxxx@gmail.com" , "emailpassword" / / 发件人账户和密码
server.sendmail(FROM,tolist,BODY)  / / 发送邮件
server.quit()



      本文转自flyingzf  51CTO博客,原文链接:http://blog.51cto.com/flyingzf/1795451,如需转载请自行联系原作者




相关文章
|
8天前
|
JSON 数据格式 Python
Python标准库中包含了json模块,可以帮助你轻松处理JSON数据
【4月更文挑战第30天】Python的json模块简化了JSON数据与Python对象之间的转换。使用`json.dumps()`可将字典转为JSON字符串,如`{"name": "John", "age": 30, "city": "New York"}`,而`json.loads()`则能将JSON字符串转回字典。通过`json.load()`从文件读取JSON数据,`json.dump()`则用于将数据写入文件。
15 1
|
9天前
|
Python 容器
python内置函数、数学模块、随机模块(二)
python内置函数、数学模块、随机模块(二)
|
9天前
|
索引 Python
python内置函数、数学模块、随机模块(一)
python内置函数、数学模块、随机模块(一)
|
12天前
|
人工智能 安全 Java
Python 多线程编程实战:threading 模块的最佳实践
Python 多线程编程实战:threading 模块的最佳实践
127 5
|
12天前
|
人工智能 数据库 开发者
Python中的atexit模块:优雅地处理程序退出
Python中的atexit模块:优雅地处理程序退出
10 3
|
15天前
|
存储 开发者 Python
Python中的argparse模块:命令行参数解析的利器
Python中的argparse模块:命令行参数解析的利器
17 2
|
15天前
|
开发者 Python
Python的os模块详解
Python的os模块详解
18 0
|
18天前
|
数据挖掘 API 数据安全/隐私保护
python请求模块requests如何添加代理ip
python请求模块requests如何添加代理ip
|
19天前
|
测试技术 Python
Python 有趣的模块之pynupt——通过pynput控制鼠标和键盘
Python 有趣的模块之pynupt——通过pynput控制鼠标和键盘
|
19天前
|
Serverless 开发者 Python
《Python 简易速速上手小册》第3章:Python 的函数和模块(2024 最新版)
《Python 简易速速上手小册》第3章:Python 的函数和模块(2024 最新版)
42 1