将标记编译为HTML的Sendmail替换
muttdown的Python项目详细描述
低声说
muttdown
是一个sendmail替换程序,设计用于mutt电子邮件客户端,该客户端将使用Markdown标准透明地将带注释的text/plain
邮件编译成text/html
。它将递归地遍历mime树并编译任何以sigil开头的text/plain
或text/markdown
部分!在标记中插入m“,它将在多部分/可选容器中与原件一起插入。
它还足够聪明,不会破坏multipart/signed
。
例如,解析之前的以下树:
- multipart/mixed
|
-- multipart/signed
|
---- text/markdown
|
---- application/pgp-signature
|
-- image/png
将编译成
- multipart/mixed
|
-- multipart/alternative
|
---- text/html
|
---- multipart/signed
|
------ text/markdown
|
------ application/pgp-signature
|
-- image/png
配置
muttdown的配置文件是使用YAML编写的。示例:
smtp_host: smtp.gmail.com
smtp_port: 587
smtp_ssl: false
smtp_username: foo@bar.com
smtp_password: foo
css_file: ~/.muttdown.css
如果不希望在配置文件中以明文形式输入密码,可以指定smtp_password_command
参数来调用shell命令来查找密码。该命令应该输出您的密码,后跟换行符,而不是其他文本。在os x上,以下调用将提取一个通用的“password”条目,应用程序设置为“mutt”,标题设置为“foo@bar.com”:
smtp_password_command: security find-generic-password -w -s mutt -a foo@bar.com
注意:如果smtp_ssl
设置为false,则muttdown
将执行非ssl会话,然后调用STARTTLS
。如果smtp_ssl
设置为true,则muttdown
将从一开始就执行ssl会话。不能用明文发送邮件。
如果设置了muttdown,它还可以使用本机sendmail
发送邮件(而不是使用smtp本身)。为此,只需将配置文件中的smtp选项留空,将sendmail
选项设置为指向sendmail
二进制文件的完全限定路径,并使用-s
标志运行muttdown
安装
使用pip install muttdown
或通过下载此包并运行python setup.py install
来安装muttdown。您将需要在requirements.txt
中指定的PyYAML和Python-Markdown库。
用法
调用为
muttdown -c /path/to/config -f "from_address" -- "to_address" [more to addresses...]
在stdin上发送一封rfc822格式的邮件。
如果未传递配置路径,则将假定为~/.muttdown.yaml
。