#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import os,sys
import getopt
import smtplib
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from subprocess import *
def sendqqmail(username,password,mailfrom,mailto,subject,content):
  gserver = 'smtp.xx.com'
  gport = 25
  try:
    msg = MIMEText(content,'plain','utf-8')
    msg['from'] = mailfrom
    msg['to'] = mailto
    msg['Reply-To'] = mailfrom
    msg['Subject'] = subject
    smtp = smtplib.SMTP(gserver, gport)
    smtp.set_debuglevel(0)
    smtp.ehlo()
    smtp.login(username,password)
    smtp.sendmail(mailfrom, mailto, msg.as_string())
    smtp.close()
  except Exception,err:
    print "Send mail failed. Error: %s" % err
def main():
  to=sys.argv[1]
  subject=sys.argv[2]
  content=sys.argv[3]
  sendqqmail('xx@xx.com','password','xx@xx.com',to,subject,content)

if __name__ == "__main__":
  main()

 

#注 :在本人测试环境已经成功,因为不是自己写的,所以有问题还请百度自行解决。

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2022-01-15
  • 2021-04-07
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
猜你喜欢
  • 2022-03-10
  • 2021-10-14
  • 2021-07-31
  • 2022-12-23
  • 2021-06-03
  • 2022-01-13
  • 2021-12-01
相关资源
相似解决方案