# -*- coding: UTF-8 -*-
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import sys
import csv
import xlrd
from pyExcelerator import *
import os
import xlwt
from xlutils.copy import copy
import pyExcelerator
import datetime
import time
reload(sys)
sys.setdefaultencoding("utf-8")
mailto_list = [""] # 邮件接收方的邮件地址
mail_host = "smtp.exmail.qq.com" # 邮件传送协议服务器
mail_user = "" # 邮件发送方的邮箱账号
mail_pass = "" # 邮件发送方的邮箱密码
def send_mail(to_list, sub, content):
me = "天才白痴梦"+"<"+mail_user+">"
msg = MIMEText(content, _subtype='plain', _charset='utf-8')
msg['Subject'] = sub # 邮件主题
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
server = smtplib.SMTP()
server.connect(mail_host)
server.login(mail_user, mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
sub = "天才白痴梦"
content = '...'
if send_mail(mailto_list, sub, content):
print "发送成功"
else:
print "发送失败"
# -*- coding: UTF-8 -*-
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import sys
import csv
import xlrd
from pyExcelerator import *
import os
import xlwt
from xlutils.copy import copy
import pyExcelerator
import datetime
import time
reload(sys)
sys.setdefaultencoding("utf-8")
mailto_list = [""] # 邮件接收方的邮件地址
mail_host = "smtp.exmail.qq.com" # 邮件传送协议服务器
mail_user = "" # 邮件发送方的邮箱账号
mail_pass = "" # 邮件发送方的邮箱密码
def send_mail(to_list, sub, content):
me = "天才白痴梦"+"<"+mail_user+">"
# 和上面的代码不同的就是,这里我们选择的是html 的格式
msg = MIMEText(content, _subtype='html', _charset='utf-8')
msg['Subject'] = sub # 邮件主题
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
server = smtplib.SMTP()
server.connect(mail_host)
server.login(mail_user, mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
sub = "天才白痴梦"
html = '<html></html>'
if send_mail(mailto_list, sub, html):
print "发送成功"
else:
print "发送失败"
def send_mail(to_list, sub, content):
me = "天才白痴梦"+"<"+mail_user+">"
msg = MIMEMultipart()
msg['Subject'] = sub # 邮件主题
msg['From'] = me
msg['To'] = ";".join(to_list)
txt = MIMEText("天才白痴梦", _subtype='plain', _charset='utf8')
msg.attach(txt)
# <b>:黑体 <i>:斜体
msgText = MIMEText('<b>Some <i>HTML</i> text</b> and an image.<img alt="" src="cid:image1" />good!', 'html', 'utf-8')
msg.attach(msgText)
file1 = "F:\\1.jpg"
image = MIMEImage(open(file1, 'rb').read())
image.add_header('Content-ID', '<image1>')
msg.attach(image)
try:
server = smtplib.SMTP()
server.connect(mail_host)
server.login(mail_user, mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
sub = "天才白痴梦"
html = '<html></html>'
if send_mail(mailto_list, sub, html):
print "发送成功"
else:
print "发送失败"
def send_mail(to_list, sub, content):
me = "天才白痴梦"+"<"+mail_user+">"
msg = MIMEMultipart()
msg['Subject'] = sub # 邮件主题
msg['From'] = me
msg['To'] = ";".join(to_list)
txt = MIMEText("天才白痴梦", _subtype='plain', _charset='utf8')
msg.attach(txt)
# # <b>:黑体 <i>:斜体
# msgText = MIMEText('<b>Some <i>HTML</i> text</b> and an image.<img alt="" src="cid:image1" />good!', 'html', 'utf-8')
# msg.attach(msgText)
#
# file1 = "F:\\1.jpg"
# image = MIMEImage(open(file1, 'rb').read())
# image.add_header('Content-ID', '<image1>')
# msg.attach(image)
att = MIMEText(open('F:\\1.jpg', 'rb').read(), 'base64', 'utf-8')
att["Content-Type"] = 'application/octet-stream'
att["Content-Disposition"] = 'attachment; filename="1.jpg"'
msg.attach(att)
try:
server = smtplib.SMTP()
server.connect(mail_host)
server.login(mail_user, mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
smtp_server = 'smtp.qq.com' smtp_port = 25 # 默认端口号为25 server = smtplib.SMTP(smtp_server, smtp_port) server.starttls() # 剩下的代码和前面的一模一样: server.set_debuglevel(1) # 打印出和SMTP服务器交互的所有信息
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有