Python实现QQ邮箱发送

简介:

具体参考代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# encoding: utf-8
 
import  smtplib
from  email.mime.text  import  MIMEText
 
 
class  MyEmail:
     def  __init__( self , subject, body):
         self .subject  =  subject
         self .body  =  body
 
         self .host  =  'smtp.qq.com'
         self .port  =  465
         self .sender  =  'sender@qq.com'
         self .pwd  =  'password'
         self .receiver  =  'receiver@qq.com'
 
     def  send_email( self ):
         msg  =  MIMEText( self .body,  'plain' 'utf-8' )
         msg[ 'subject' =  self .subject
         msg[ 'from' =  self .sender
         msg[ 'to' =  self .receiver
 
         =  smtplib.SMTP_SSL( self .host,  self .port)
         s.login( self .sender,  self .pwd)
         s.sendmail( self .sender,  self .receiver, msg.as_string())
 
 
if  __name__  = =  '__main__' :
     my_email  =  MyEmail( '这是一封测试邮件' '这是一封测试邮件,请不要回复,谢谢' )
     my_email.send_email()




本文转自 许大树 51CTO博客,原文链接:http://blog.51cto.com/abelxu/1873328,如需转载请自行联系原作者
相关文章
|
网络协议 Python
154 python网络编程 - TCP案例(模拟QQ聊天)
154 python网络编程 - TCP案例(模拟QQ聊天)
244 0
|
前端开发 Python
【Python • 项目实战】pytesseract+pyqt实现图片识别软件小项目——(二)实现QQ截图功能
【Python • 项目实战】pytesseract+pyqt实现图片识别软件小项目——(二)实现QQ截图功能
644 0
|
存储 SQL 关系型数据库
Python实现给qq自动发消息 终于有人来和我说早安晚安了吗...
Python实现给qq自动发消息 终于有人来和我说早安晚安了吗...
|
Windows Python
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
569 0
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
|
API Python
Python邮箱API发送邮件的方法和步骤
使用Python发送邮件涉及导入smtplib和email模块,设置发件人、收件人、主题和内容,然后连接SMTP服务器(如示例中的smtp.example.com)并使用SMTP方法发送。完整代码示例包括异常处理,确保邮件发送成功或提供错误信息。通过这种方式,可以实现Python的自动化邮件发送功能。
用Python实现QQ/微信消息轰炸
用Python实现QQ/微信消息轰炸
|
API Python
做一个合格的男友,用python制作每天定时给女朋友发送邮箱问候
做一个合格的男友,用python制作每天定时给女朋友发送邮箱问候
255 0
|
开发者 Python
用 Python 将 QQ 好友头像生成祝福语
用 Python 将 QQ 好友头像生成祝福语
289 0
用 Python 将 QQ 好友头像生成祝福语
|
算法 大数据 Python
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现
328 2
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现
|
Python
【代码】利用Python每天自动发新闻到邮箱
【代码】利用Python每天自动发新闻到邮箱
179 0

推荐镜像

更多