python2.4 发送邮件

简介:

import smtplib
#from email.mime.text import MIMEText
from email.MIMEText import MIMEText
def send_email(content):

    sender = "lgl15984@163.com"
    receiver = [xxx@qq.com]
    host = '220.181.12.16'
    port = 465
    msg = MIMEText(content)
    msg['From'] = "lgl15984@163.com"
    msg['To'] = "xxxx@qq.com"
    msg['Subject'] = "backup check"

    try:
        smtp = smtplib.SMTP()
        smtp.connect('220.181.12.16:25')
#       smtp.ehlo()
#       smtp.starttls()
#       smtp.ehlo()

#        smtp = smtplib.SMTP_SSL(host, port)
        smtp.login(sender, 'xxxx')
        smtp.sendmail(sender, receiver, msg.as_string())
#        getlog().info("send email success")
    except Exception, e:
#        get_log().error(e)
        print 'email fail'
        print e
        pass
send_email('aaa')




本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/1617114

相关文章
|
3月前
|
数据安全/隐私保护 Python
Python实现邮件发送(含详细设置方法),并总结自己遇到的错误
Python实现邮件发送(含详细设置方法),并总结自己遇到的错误
|
5天前
|
数据安全/隐私保护 Python
如何使用Python自动发送邮件?
如何使用Python自动发送邮件?
9 1
|
20天前
|
监控 网络协议 网络安全
SMTP操作使用详解并通过python进行smtp邮件发送示例
SMTP操作使用详解并通过python进行smtp邮件发送示例
30 3
|
2月前
|
Python
python发送邮件
python发送邮件
19 1
|
2月前
|
数据安全/隐私保护 Python
如何使用 Python 发送邮件
如何使用 Python 发送邮件
|
1月前
|
机器学习/深度学习 数据采集 自然语言处理
Python基于词袋模型特征和TFIDF特征进行支持向量机模型中文邮件分类项目实战
Python基于词袋模型特征和TFIDF特征进行支持向量机模型中文邮件分类项目实战
|
2月前
|
网络安全 数据安全/隐私保护 Python
Python SMTP发送邮件
Python SMTP发送邮件
|
2月前
|
Windows Python
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
每日自动发邮件(Python +QQ邮箱 + Windows 10定时任务)
|
3月前
|
安全 数据安全/隐私保护 开发者
Python实现简单的邮件发送系统
Python实现简单的邮件发送系统
46 3
|
3月前
|
运维 Shell Linux
第十四章 Python发送邮件(常见四种邮件内容)
第十四章 Python发送邮件(常见四种邮件内容)