使用降价或基于ansi代码的内容的邮件发送python/cli接口

emili的Python项目详细描述


发送邮件的简单界面。转换输入格式,如标记 或者控制台输出使用ansi颜色转换成漂亮的双纯文本/html 信息。

模块使用

importemilicontent="""
# 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',)

现在需要一个包含配置的config.py文件 名为smtp的字典中的SMTP连接选项:

smtp=dict(host='smtp.acme.cat',port='',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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaSpringbean已创建但未自动连接   java LibGDX游戏在三星Galaxy Grand Prime上结束   如何在Java中列出字符串句子中所有匹配条件的单词   java在Recyclerview中使用“putExtra”传递数据   java从一个特定的数组中提取特定的JSON对象,以便在Android中通过一个意图放入另一个活动   java需要使用IntelliJ和设置项目SDK的帮助   java springcontextindexer和Swagger 3   java使用indexOf和substring计算数字   java使用xml解析在word文档中查找隐式分页符   在添加<context:componentscan basepackage=“com.young.user”/   java无条件更改JTable单元格的背景色   选择列表中的java调用oracle函数:节点无数据类型   java如何添加缓冲图像作为JFrame的背景,然后在此图像上添加面板?   java Javadoc找不到用scala编写的类   java连接到文件共享程序的IP地址   java将数组元素加载到集合中   Tomcat中的java servlet、过滤器和线程   非Bean对象中的java EJB CDI注入?   java与println和printf的不同舍入