Python发送邮件

#!/usr/bin/python
# -*- coding: utf-8 -*-
# 作者:昨夜星辰
import smtplib
import string

HOST = '发件邮件服务器地址'
SUBJECT = '主题'
TO = '收件人邮箱'
FROM = '发件人邮箱'
TEXT = '''内容'''
BODY = string.join((
    'From: %s' % FROM,
    'To: %s' % TO,
    'Subject: %s' % SUBJECT,
    '',
    TEXT
),'\r\n')
server = smtplib.SMTP()
server.connect(HOST,'25')
server.login('发件人邮箱','密码')
server.sendmail(FROM,[TO],BODY)
server.quit()

你可能感兴趣的:(python,邮件)