zoukankan      html  css  js  c++  java
  • python——SMTP发送简单邮件

    [root@localhost python]# cat smtp.py 
    import smtplib
    import string
    from email.mime.text import MIMEText
    HOST = "smtp-mail.outlook.com"
    FROM = "bp1260647530@outlook.com"
    SUBJECT = "this is a test"
    TO = "1260647530@qq.com"
    TEXT = "good to see you"
    BODY = string.join((
    "from: %s" % FROM,
    "to: %s" % TO,
    "Subject: %s" % SUBJECT, 
    "",TEXT
    ),"
    ")
    server=smtplib.SMTP()
    server.connect(HOST,"25")    #这个端口貌似不对,不过好像没影响
    server.starttls()
    server.login("bp1260647530@outlook.com","我的密码")
    server.sendmail(FROM,TO,BODY)
    server.close()
    [root@localhost python]# 
    

    查看邮箱,接受正常  

    本来想用QQ邮箱做实验,结果发现需要万恶的授权码,果断弃用,改用outlook邮箱,这个邮箱就没有这么流氓

  • 相关阅读:
    MySql
    Zookeeper
    Kafka
    Mybatis
    Spring/Spring MVC
    Spring Boot/Spring Cloud
    网络
    设计模式
    Strassen algorithm(O(n^lg7))
    dynamic programming:find max subarray
  • 原文地址:https://www.cnblogs.com/biaopei/p/8466183.html
Copyright © 2011-2022 走看看