Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
如果这是一项常规任务,请安装Mailman(如果您不这样做)还没有)并学习如何使用它。
If this is going to be a regular task, install Mailman (if you don't already have it) and learn how to use it.
这是一个脚本,可以用于使用 Gmail 或 Google 域应用电子邮件帐户发送电子邮件。它使用 Google 的 SMTP 服务器,因此您无需在本地配置。
使用其“邮件”功能,可以轻松发送消息。例如:
如果您不需要附件,您可以轻松修改“mail”函数以删除“attach”,或者将其设为可选关键字参数。
Here is a script that can be used to send an email using a gmail or Google domain apps email account. It uses Google's SMTP server, so you don't need to configure one locally.
Using its 'mail' function, it's easy to send a message. For example:
You could easily modify the 'mail' function to remove 'attach' if you don't want an attachment, or make it an optional keyword argument.
最简单的方法是将 python 程序的输出通过管道传输到适当配置的系统上的 mail 命令:(
对于 PC 上的 Ubuntu,这可能意味着使用来自 ISP 的 SMTP 服务器作为 exim 或另一个 MTA 的智能主机)
如果没有不用说,您将希望让您的 python 脚本与某些邮件服务器(通常使用 SMTP)通信。有一个 python 库 ,请参阅 这个问题用于生成 MIME 的示例,也可能是其他问题。
The simplest way is to pipe the output of your python program to the mail command on an appropriately configured system:
(For Ubuntu on your PC that probably means using the SMTP servers from your ISP as a smarthost for exim or another MTA)
If that doesn't cut it you're going to want to make your python script talk to some mailserver(s), usually using SMTP. There's a python library for this, see this question for an example generating MIME and probably others too.