使用降价或基于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第三方库


热门话题
如何为本地和Jenkins执行实现Java配置?   多日志文件创建的java log4j滚动追加器问题   安卓 java替换列表内容或替换引用值本身   java JOptionPane如何不尊重同步?   java Spring状态机访问eventNotAccepted侦听器中的StateContext   Java中的快速排序算法程序   java私有静态最终双精度为0   java中ByteBuffer的clear()方法   同步Java可重入锁的正确锁定/解锁用法   java拦截Couchbaselite中的CRUD操作   用于搜索广告的active directory Java程序   java为什么netty的handler成员变量在使用新handler()处理请求时不重置   java Mockito验证(…)fails“实际上,与此模拟没有任何交互。”按顺序在多个测试运行中   java为什么我的Alarmmanager在终止我的应用程序后不工作?   java如何正确排序groovy列表   一段时间后,java OAuth“401:无效凭据”   使用jtable和数据库在javaswing中进行分页   java如何在Android中将ASCII字符转换为字符串?   java如何运行。来自Javascript的jar方法   java Apache vfs:获取目录的最新更改文件(sftp)