zoukankan      html  css  js  c++  java
  • email_fun.py

    import smtplib
    from email.mime.text import MIMEText
    from email.utils import formataddr

    def mail():
      ret = 123
      try:
        msg = MIMEText('the mail contents', 'plain', 'utf-8')
        msg['From'] = formataddr(['NameA', 'Email_addr_S'])
        msg['To'] = formataddr(['nameB', 'Email_addr_R'])
        msg['Subject'] = "Subject"

        server = smtplib.SMTP('smtp.126.com', 25)
        server.login('Email_addr_S','PSD')
        server.sendmail('Email_addr_S',['Email_addr_R',],msg.as_string())
        server.quit
      except Exception:

        ret = 456
      return ret

    ret = mail()
    print(ret)

    mail_fun.py

    import smtplib
    from email.mime.text import MIMEText
    from email.utils import formataddr

    class mail():
      classSpec = "it is a test class"
      def __init__(self,UserName,UserAddr):
        self.UserName = UserName
        self.UserAddr = UserAddr

      def mail():

        ret = True
        try:
          msg = MIMEText('the mail contents', 'plain', 'utf-8')
          msg['From'] = formataddr(['NameA', 'Email_addr_S'])
          msg['To'] = formataddr(['nameB', 'Email_addr_R'])
          msg['Subject'] = "Subject"

          server = smtplib.SMTP('smtp.126.com', 25)
          server.login('Email_addr_S','PSD')
          server.sendmail('Email_addr_S',['Email_addr_R',],msg.as_string())
          server.quit
        except Exception:

          ret = False

        return ret

    email_call.py

    #! /usr/lib/python3.5

    import mail_fun

    worker1 = mail_fun.mail('xxx', 'xxxx@qq.com')
    ret = worker1.Semail()
    if ret:
      print('sent already')
    else:
      print('failed to send the email')

  • 相关阅读:
    js 字符串操作函数
    loadscript加载
    jquery.cookie.js结合asp.net实现最近浏览记录
    .net 关于匿名类型的特性
    高级javaScript程序形成过程(进阶)
    javascript window.*
    Jquery遍历筛选数组的几种方法和遍历解析json对象|Map()方法详解
    javascript prototype
    Jquery 中的CheckBox、 RadioButton、 DropDownList的取值赋值
    jquery笔记
  • 原文地址:https://www.cnblogs.com/tlfox2006/p/7229198.html
Copyright © 2011-2022 走看看