600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > python用smtp发邮件怎么抄送_Python发送邮件并抄送

python用smtp发邮件怎么抄送_Python发送邮件并抄送

时间:2023-01-27 23:27:47

相关推荐

python用smtp发邮件怎么抄送_Python发送邮件并抄送

#!/usr/bin/env python

#coding:utf-8

import smtplib,time,string

from email.mime.text import MIMEText

from email.MIMEMultipart import MIMEMultipart

def send_mail(subject,message):

SMTPserver = ‘qq 的 smtp server‘

sender = ‘[emailprotected]‘

password = "1234567"

To = [‘[emailprotected]‘,‘[emailprotected]‘]

#To = [‘[emailprotected]‘,]

Cc = [‘[emailprotected]‘,‘[emailprotected]‘]

msg = MIMEMultipart()

msg.attach(MIMEText(message, ‘html‘,‘UTF-8‘))

msg[‘Subject‘] = subject

msg[‘From‘] = sender

msg[‘To‘] = ",".join(To)

msg[‘Cc‘] = ‘,‘.join(Cc)

try:

mailserver = smtplib.SMTP(SMTPserver,25)

mailserver.login(sender,password)

mailserver.sendmail(sender,To,msg.as_string())

mailserver.quit()

print ‘send email success ‘

except smtplib.SMTPException:

print "Error: "

mes=open(‘redis_cluster.html‘,‘a+‘).read()sub="Create valueadded cluster info "send_mail(sub,mes)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。