python笔记系列:发送电子邮件模块smtplib
2018-03-26 13:59
453 查看
发送电子邮件模块smtplibSMTP类定义:smtplib.SMTP([host[,port[,local_hostname[,timeout]]]]) port默认25SMTP.connect(host[,port]) eg:SMTP.connect("smtp.163.com","25")SMTP.login(user,password)SMTP.sendmail(from_addr,to_addrs,msg[,mail_potions,rcpt_options])msg内部定义如下:“”“From:aaa@163.comTo:bbb@qq.comSubject:test mail
test mail body"""SMTP.starttls([keyfild[,certfile]]) 启用TLS(安全传输)模式,所有SMTP指令都将加密传输SMTP.quit()
邮件发送示例代码#!/usr/bin/pythonimport smtplibimport string HOST = "smtp.ym.163.com"SUBJECT = "Test email from huwy"TO = "276473849@qq.com"FROM = "sam_hu@novowater.com.cn"text = "Python rules them all!"BODY = string.join(( "From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT , "", text ), "\r\n")server = smtplib.SMTP()server.connect(HOST,"25")server.starttls()server.login("sam_hu@novowater.com.cn","123456")server.sendmail(FROM, [TO], BODY)server.quit()
定制个性化的邮件格式方法:MIME,将纯文本格式扩展到html,支持附件、音频、图片等格式email.mime.multipart.MIMEMultipartemail.mime.audio.MIMEAudioemail.mime.image.MIMEImageemail.mime.text.MIMEText
发送电子邮件模块smtplibSMTP类定义:smtplib.SMTP([host[,port[,local_hostname[,timeout]]]]) port默认25SMTP.connect(host[,port]) eg:SMTP.connect("smtp.163.com","25")SMTP.login(user,password)SMTP.sendmail(from_addr,to_addrs,msg[,mail_potions,rcpt_options])msg内部定义如下:“”“From:aaa@163.comTo:bbb@qq.comSubject:test mail
test mail body"""SMTP.starttls([keyfild[,certfile]]) 启用TLS(安全传输)模式,所有SMTP指令都将加密传输SMTP.quit()
邮件发送示例代码#!/usr/bin/pythonimport smtplibimport string HOST = "smtp.ym.163.com"SUBJECT = "Test email from huwy"TO = "276473849@qq.com"FROM = "sam_hu@novowater.com.cn"text = "Python rules them all!"BODY = string.join(( "From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT , "", text ), "\r\n")server = smtplib.SMTP()server.connect(HOST,"25")server.starttls()server.login("sam_hu@novowater.com.cn","123456")server.sendmail(FROM, [TO], BODY)server.quit()
定制个性化的邮件格式方法:MIME,将纯文本格式扩展到html,支持附件、音频、图片等格式email.mime.multipart.MIMEMultipartemail.mime.audio.MIMEAudioemail.mime.image.MIMEImageemail.mime.text.MIMEText
test mail body"""SMTP.starttls([keyfild[,certfile]]) 启用TLS(安全传输)模式,所有SMTP指令都将加密传输SMTP.quit()
邮件发送示例代码#!/usr/bin/pythonimport smtplibimport string HOST = "smtp.ym.163.com"SUBJECT = "Test email from huwy"TO = "276473849@qq.com"FROM = "sam_hu@novowater.com.cn"text = "Python rules them all!"BODY = string.join(( "From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT , "", text ), "\r\n")server = smtplib.SMTP()server.connect(HOST,"25")server.starttls()server.login("sam_hu@novowater.com.cn","123456")server.sendmail(FROM, [TO], BODY)server.quit()
定制个性化的邮件格式方法:MIME,将纯文本格式扩展到html,支持附件、音频、图片等格式email.mime.multipart.MIMEMultipartemail.mime.audio.MIMEAudioemail.mime.image.MIMEImageemail.mime.text.MIMEText
发送电子邮件模块smtplibSMTP类定义:smtplib.SMTP([host[,port[,local_hostname[,timeout]]]]) port默认25SMTP.connect(host[,port]) eg:SMTP.connect("smtp.163.com","25")SMTP.login(user,password)SMTP.sendmail(from_addr,to_addrs,msg[,mail_potions,rcpt_options])msg内部定义如下:“”“From:aaa@163.comTo:bbb@qq.comSubject:test mail
test mail body"""SMTP.starttls([keyfild[,certfile]]) 启用TLS(安全传输)模式,所有SMTP指令都将加密传输SMTP.quit()
邮件发送示例代码#!/usr/bin/pythonimport smtplibimport string HOST = "smtp.ym.163.com"SUBJECT = "Test email from huwy"TO = "276473849@qq.com"FROM = "sam_hu@novowater.com.cn"text = "Python rules them all!"BODY = string.join(( "From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT , "", text ), "\r\n")server = smtplib.SMTP()server.connect(HOST,"25")server.starttls()server.login("sam_hu@novowater.com.cn","123456")server.sendmail(FROM, [TO], BODY)server.quit()
定制个性化的邮件格式方法:MIME,将纯文本格式扩展到html,支持附件、音频、图片等格式email.mime.multipart.MIMEMultipartemail.mime.audio.MIMEAudioemail.mime.image.MIMEImageemail.mime.text.MIMEText
相关文章推荐
- Python使用smtplib模块发送电子邮件的流程详解
- python 发送电子邮件模块smtplib
- python学习笔记之使用smtplib模块发送邮件
- python发送电子邮件模块smtplib
- Python使用smtplib模块发送电子邮件的流程详解
- 通过python操作smtplib模块发送邮件
- python模块smtplib实现纯文本邮件发送功能
- Python_使用smtplib和email模块发送邮件
- python笔记系列:数据报表之Excel操作模块:XlsxWriter
- python中使用smtplib和email模块发送邮件实例
- Python学习笔记(十四)——发送电子邮件和短信
- Python3 使用smtplib和email模块发送邮件
- PYTHON模块学习之邮件发送模块smtplib(2015-4-3)
- 使用python内置smtplib模块发送邮件
- python中使用smtplib和email模块发送邮件实例
- python学习笔记系列----(四)模块
- Python_使用smtplib和email模块发送邮件
- Python_使用smtplib和email模块发送邮件
- python3模块smtplib实现发送邮件功能
- 发送电子邮件模块smtplib