python使用sendmail在linux下发送邮件
来源:互联网 发布:php高并发实战 编辑:程序博客网 时间:2024/06/04 20:05
参考链接:How do I send mail from a Python script?
使用linux下的sendmail程序来发送邮件,利用popen函数(python docs关于popen函数)可以直接调用linux系统程序,需要指定程序所在的位置。
#!/usr/bin/python# -*- coding: UTF-8 -*- #Author: Victor LvSENDMAIL = "/usr/sbin/sendmail" #sendmail(可执行程序)所在的路径sender = "sender@example.com" receivers = ["user1@example.com", "user2@example.com"]subject = "这是邮件标题"text = "这是邮件正文。"#将这些元素组合成一条messagemessage = """\From: %sTo: %sSubject: %s%s""" % (sender, ", ".join(receivers), subject, text)# Send the mailimport osp = os.popen("%s -t -i" % SENDMAIL, "w")p.write(message)status = p.close()if status: print "Sendmail exit status", status
python docs中关于发送邮件的其他方法和例子:
email: Examples
0 0
- python使用sendmail在linux下发送邮件
- Linux下sendmail发送邮件
- Linux下sendmail发送邮件
- 使用LINUX SENDMAIL发送邮件
- Linux sendmail发送邮件
- 使用sendmail发送邮件
- 使用sendMail发送邮件
- python调用sendmail发送邮件
- Linux 下使用sendmail搭建邮件服务器
- Linux -- 测试sendmail邮件发送
- linux sendmail mutt 发送邮件
- linux/unix 下 删除sendmail -bp 邮件队列;查看sendmail发送邮件日志
- 在Centos7下捣鼓邮件发送软件sendmail与postfix
- phpmailer使用sendmail发送邮件
- php使用sendMail发送邮件
- Linux下通过Sendmail给外部邮箱发送邮件
- Linux SendMail 使用外部SMTP服务发送邮件
- Linux中使用PostFix代替Sendmail 发送邮件
- jsp语言基础
- Object Detection
- iOS常用的传值方式详解
- Cannot find table rule and default data source with logic table
- FTP上传下载
- python使用sendmail在linux下发送邮件
- ReentrantLock(三):公平锁与非公平锁
- rabbitmq消息和队列持久化
- 前端之工具
- HttpClient使用详解
- 100篇文章回想
- [Leetcode.Array]561. Array Partition I Add to List
- Git操作失败并提示Another git process seems to be running in this......
- poj2516(最小费最大流)