当前位置:天才代写 > tutorial > Python教程 > python 发送邮件

python 发送邮件

2018-05-17 08:00 星期四 所属: Python教程 浏览:514

python">#!/usr/bin/env python
#_*_encoding:utf-8_*_
import smtplib
import string
FROM = raw_input("请输入您的邮箱地址:")
FROM_PASS = raw_input("请输入您的邮箱密码:")
HOST = raw_input("请输入您的邮箱SMTP服务器地址(例如:smtp.qq.com:):")
TO = raw_input("请输入对方邮箱地址:")
SUBJECT = "Mail"
text = "This is a test mail !"
BODY = string.join((
        "FROM: %s" % FROM,
        "TO: %s" % TO,
        "Suject: %s" % SUBJECT,
        "",
        text
        ),"\r\n")
server = smtplib.SMTP()
server.connect(HOST,"25")
server.login(FROM,FROM_PASS)
server.sendmail(FROM,[TO],BODY)
server.quit()

标签:python

 

    关键字:

天才代写-代写联系方式