使用基于Markdown或ANSI代码的内容发送邮件的Python/CLI接口
项目描述
Emili
简单的邮件发送界面。将Markdown或使用ANSI颜色的控制台输出等输入格式转换为漂亮的纯文本/HTML消息。
模块使用
import emili
content = """
# this is a title
Read **this** is very _important_!!
"""
emili.sendmail(
from = "me@acme.cat",
to = [ "abe@acme.cat", "bill@acme.cat" ],
bcc = [ "me@acme.cat" ],
subject = "About this email"
md = content,
attachments = [ 'onefile.pdf' ],
config = '../config.py',
)
目前需要一个包含SMTP连接配置选项的config.py文件,名为smtp
字典
smtp=dict(
host='smtp.acme.cat',
port=465,
user='roadrunner@acme.cat',
password='mecmec',
)
命令行使用
usage: emili.py [-h] -f SENDER -s SUBJECT -t recipient [--body TEXT]
[--bodyfile BODYFILE] [-C CONFIG.PY] [-c CC] [-b BCC]
[-r REPLYTO] [--format FORMAT] [--style CSSFILE]
[--template TEMPLATE] [--dump OUTPUTFILE.eml]
[FILE [FILE ...]]
Sends an email.
positional arguments:
FILE File to attach
optional arguments:
-h, --help show this help message and exit
-f SENDER, --from SENDER
Message sender ('From:' header)
-s SUBJECT, --subject SUBJECT
Message subject ('Subject:' header)
-t recipient, --to recipient
Message recipient ('To:' header) (multiple)
--body TEXT Message body (defaults to stdin)
--bodyfile BODYFILE File containing the message body (defaults to stdin)
-C CONFIG.PY, --config CONFIG.PY
Python Module with smtp configuration defined.
-c CC, --cc CC Message copy recipient ('CC:' header) (multiple)
-b BCC, --bcc BCC Message hidden copy recipient ('BCC:' header)
(multiple), other recipients won't see this header
-r REPLYTO, --replyto REPLYTO
Default address to reply at ('Reply-To:' header)
(multiple)
--format FORMAT Format for the body. 'md' takes markdown and generates
both html and text. 'ansi' does the same, turning ANSI
color codes in html or stripping them for text.
--style CSSFILE Style sheet for the html output, (multiple)
--template TEMPLATE Alternative template for the html body.
--dump OUTPUTFILE.eml
Instead of sending, dump the email into a file
reportrun
usage: reportrun [-h] -s SUBJECT -t RECIPIENT [-f SENDER] [-C CONFIG.PY]
[FILE [FILE ...]] -- COMMAND [COMMAND_ARG ...]
reportrun wraps the execution of a command and sends an email
whenever the command fails. The mail sending is processed by
emili so that ansi codes and spacing are shown properly.
positional arguments:
FILE File to attach
COMMAND Command to run
COMMAND_ARG Argument for COMMAND
optional arguments:
-f SENDER, --from SENDER
Message sender ('From:' header)
-s SUBJECT, --subject SUBJECT
Message subject ('Subject:' header)
-t recipient, --to recipient
Message recipient ('To:' header) (multiple)
-C CONFIG.PY, --config CONFIG.PY
Python Module with smtp configuration defined.
-a, --always
Sends even if the command does not fail.
--
Marks the start of the command to execute.
变更日志
1.6 (2019-10-09)
- 修复:reportrun忽略换行符
- reportrun接受附件
- reportrun --help选项,并在README中进行了文档说明
1.5 (2018-10-15)
- 添加
reportrun
脚本
1.4 (2017-07-02)
- 修复:dump不需要配置
1.3 (2016-11-02)
--dump
选项将结果邮件作为文件输出而不是发送- 修复:更好地处理格式为
Me <me@here.org>
的地址 - 修复:不要将完整路径作为附件名称
activate_wrapper.sh
已移动到somenergia-utils
存储库
1.2 (2016-03-28)
- 选项
-c
/--config
用于显式配置文件 - 添加包装器
execute_send_mail.sh
- 添加包装器
activate_wrapper.sh
1.1 (2016-01-12)
- 在PyPi上可用
1.0 (2016-01-12)
- 第一个版本
项目详情
关闭
emili-1.6.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4cc25aa57ef4f7f677605d586ebc7c20357975bb03b472fe9c105b73a7e69e3d |
|
MD5 | d3bfb59941a72e8c05d5bed74af1eb37 |
|
BLAKE2b-256 | d3b01ea72d154b6fd4e299fea958b1704c9721c845d7eb67d02134f6ab9dd801 |