python import smtplib

remyyoung 发布于 2016/01/07 21:19
阅读 101
收藏 0

代码如下:

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import smtplib


sender = 'from@fromdomain.com'
receivers = ['to@todomain.com']


message = """
From: from person<from@fromdomain.com>
To  : to person <to@todomain.com>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
    smtpObj = smtplib.SMTP('localhost')
    smtpObj.sendmail(sender,receivers,message)
    print("Successfully send mail")
except SMTPException:
    print("Error: unable to send email"



加载中
返回顶部
顶部