zoukankan      html  css  js  c++  java
  • sendmail

     通过QQ邮箱发送邮件

    #coding:utf8
    
    import  email
    import  smtplib
    from email.mime.text import  MIMEText
    from email.header import Header
    from email.mime.multipart import MIMEMultipart
    from  email.mime.image import  MIMEImage
    from  email.mime.application import MIMEApplication
    import  os
    
    sender = '2578201379@qq.com'
    receivers = 'xxxxxxxx@qq.com'
    subject = 'python test sendmail'
    smtpserver = 'smtp.qq.com'
    username = '2578201379@qq.com'
    password = '111111111'
    
    message = MIMEMultipart()
    message['From'] = sender
    message['To'] = receivers
    message['Subject'] = subject
    
    context = "<h1>大家好:</h1>这个是正文"
    message.attach(MIMEText('{0}'.format(context), 'plain', 'utf-8'))
    
    server = smtplib.SMTP_SSL()
    server.connect(smtpserver, '465')
    server.login(username, password)
    server.sendmail(sender, receivers, message.as_string())
    server.quit()

    发送结果:

  • 相关阅读:
    Windows下输入法全角符,半角符的切换
    hdu 2546 饭卡
    hdu 1712 ACboy needs your help
    hdu 3033 I love sneakers!
    hdu 1171 Big Event in HDU
    hdu 1114 Piggy-Bank
    HDU 1058 Humble Numbers
    hdu 1297
    hdu 2050
    hdu 2563
  • 原文地址:https://www.cnblogs.com/pythonlx/p/8241564.html
Copyright © 2011-2022 走看看