#!/usr/bin/python
import smtplib
from email.Message import Message
from time import sleep

smtpserver='smtp.gmail.com'
username='hzhida95@gmail.com'
password='*******'
from_addr='hzhida95@gmail.com'
to_addr='hzhida2011@gmail.com'
cc_addr='1241224798@qq.com'

message=Message()
message['Subject']='Mail Subject'
message['From']=from_addr
message['To']=to_addr
message['Cc']=cc_addr
message.set_payload('mail content')
msg=message.as_string()

sm=smtplib.SMTP(smtpserver,port=587,timeout=20)
sm.set_debuglevel(1)
sm.ehlo()
sm.starttls()
sm.ehlo()
sm.login(username,password)
sm.sendmail(from_addr,to_addr,msg)
sleep(5)
sm.quit()

相关文章:

  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-12-27
  • 2022-02-02
猜你喜欢
  • 2021-11-16
  • 2021-12-01
  • 2021-08-05
  • 2021-12-13
  • 2021-12-16
  • 2021-08-15
  • 2021-12-28
相关资源
相似解决方案