python类SMTP_SSL的实例源码

password.py 文件源码 项目:MonkeyEye-Server 作者: SYSUMonkeyEye 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def sendEmail(self, key, From, To, type):
        try:
            s = '??' if type == 'pay' else ''
            msg = MIMEText('?????????%s????????30?????????????????\n' % s,
                           'plain', 'utf-8')
            msg["Subject"] = '?MonkeyEye? %s????' % s
            msg["From"] = From
            msg["To"] = To

            s = smtplib.SMTP_SSL("smtp.qq.com", 465)
            s.login(From, key)

            s.sendmail(From, To, msg.as_string())
            s.close()
            return True
        except Exception:
            return False
d_send_email_on_internet.py 文件源码 项目:gps_tracker 作者: kostiskag 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def send_email(text):
  #send_email = False
  send_email = True
  st = datetime.datetime.fromtimestamp(time.time()).strftime('%d-%m-%Y %H:%M:%S')
  msg = MIMEText(text+"\nData captured at: "+st)

  me =   configure.EMAIL_ADDRESS
  you =  configure.DESTINATION_EMAIL

  msg['Subject'] = 'GPS Tracker'
  msg['From'] = me
  msg['To'] = you

  if send_email:
    s = smtplib.SMTP_SSL('smtp.gmail.com:465')
    s.login(configure.EMAIL_ADDRESS, configure.EMAIL_PASSWORD)
    s.sendmail(me, [you], msg.as_string())
    s.quit()
d_send_email_on_fix.py 文件源码 项目:gps_tracker 作者: kostiskag 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def send_email(text):
  #send_email = False
  send_email = True
  st = datetime.datetime.fromtimestamp(time.time()).strftime('%d-%m-%Y %H:%M:%S')
  msg = MIMEText(text+"\nData captured at: "+st)

  me =   configure.EMAIL_ADDRESS
  you =  configure.DESTINATION_EMAIL

  msg['Subject'] = 'GPS Tracker'
  msg['From'] = me
  msg['To'] = you

  if send_email:
    s = smtplib.SMTP_SSL('smtp.gmail.com:465')
    s.login(configure.EMAIL_ADDRESS, configure.EMAIL_PASSWORD)
    s.sendmail(me, [you], msg.as_string())
    s.quit()
concordsvr.py 文件源码 项目:device-concord4 作者: csdozier 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def send_email(user, pwd, recipient, subject, body):
    import smtplib

    gmail_user = user
    gmail_pwd = pwd
    FROM = user
    TO = recipient if type(recipient) is list else [recipient]
    SUBJECT = subject
    TEXT = body

    # Prepare actual message
    message = """From: %s\nTo: %s\nSubject: %s\n\n%s
    """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
    try:
        server_ssl = smtplib.SMTP_SSL("smtp.gmail.com", 465)
        server_ssl.ehlo()
        server_ssl.login(gmail_user, gmail_pwd)
        server_ssl.sendmail(FROM, TO, message)
        server_ssl.close()
        log.info("E-mail notification sent")
    except Exception, ex:
        log.error("E-mail notification failed to send: %s" % str(ex))
emailer.py 文件源码 项目:jx-sqlite 作者: mozilla 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __enter__(self):
        if self.server is not None:
            Log.error("Got a problem")

        if self.settings.use_ssl:
            self.server = smtplib.SMTP_SSL(self.settings.host, self.settings.port)
        else:
            self.server = smtplib.SMTP(self.settings.host, self.settings.port)

        if self.settings.username and self.settings.password:
            self.server.login(self.settings.username, self.settings.password)

        return self
flask_mail.py 文件源码 项目:Flask_Blog 作者: sugarguo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def configure_host(self):
        if self.mail.use_ssl:
            host = smtplib.SMTP_SSL(self.mail.server, self.mail.port)
        else:
            host = smtplib.SMTP(self.mail.server, self.mail.port)

        host.set_debuglevel(int(self.mail.debug))

        if self.mail.use_tls:
            host.starttls()
        if self.mail.username and self.mail.password:
            host.login(self.mail.username, self.mail.password)

        return host
recipe-578203.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def login(self, username, password):
        self.M = imaplib.IMAP4_SSL(self.IMAP_SERVER, self.IMAP_PORT)
        self.S = smtplib.SMTP_SSL(self.SMTP_SERVER, self.SMTP_PORT)
        rc, self.response = self.M.login(username, password)
        sc, self.response_s = self.S.login(username, password)
        self.username = username
        return rc, sc
Smail.py 文件源码 项目:Smail 作者: Aliencn 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def send(self):
        if len(self.attachment_list) == 0:
            self.msg = MIMEText(self.content, self.mail_type, self.charset)
        else:
            self.msg = MIMEMultipart()
            self.msg.attach(MIMEText(self.content, self.mail_type, self.charset))
            for attachment in self.attachment_list:
                self.msg.attach(attachment)

        self.msg['Subject'] =Header(self.subject,self.charset)
        self.msg['From'] = self.server_from_addr
        self.msg['To'] = ",".join(self.to_addr)
        if self.cc_addr:
            self.msg['cc'] = ",".join(self.cc_addr)
        if self.bcc_addr:
            self.msg['bcc'] = ",".join(self.bcc_addr)

        #send
        for a in range(self.try_time):
            try:
                if self.smtp_port == 25:
                    server = smtplib.SMTP(self.smtp_server, self.smtp_port,timeout=self.time_out)
                else:
                    server = smtplib.SMTP_SSL(self.smtp_server, self.smtp_port,timeout=self.time_out)
                #server.set_debuglevel(1)
                server.login(self.smtp_user,self.smtp_pass)
                server.sendmail(self.server_from_addr,self.server_to_addrs,self.msg.as_string())
                server.quit()
                break
            except Exception as e:
                print(e)
gmail.py 文件源码 项目:sndlatr 作者: Schibum 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, user, access_token):
        self.client = smtplib.SMTP_SSL('smtp.gmail.com')
        # self.client.set_debuglevel(4)
        self._login(user, access_token)
pyMail.py 文件源码 项目:zabbix_manager 作者: BillWang139967 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, user, passwd, smtp,port,usettls=False):
        self.mailUser = user  
        self.mailPassword = passwd
        self.smtpServer = smtp
        self.smtpPort   = port
        if usettls:
            smtp_class = smtplib.SMTP_SSL
        else:
            smtp_class = smtplib.SMTP
        self.mailServer = smtp_class(self.smtpServer, self.smtpPort)  
        self.mailServer.ehlo()  
        self.mailServer.login(self.mailUser, self.mailPassword)
        self.msg = MIMEMultipart()

    #????????mailserver


问题


面经


文章

微信
公众号

扫码关注公众号