Skip to main content

命令行邮件发送工具

Project description

smtp-send

Actions PyPI

由于在自动化环境中大量依赖环境变量和命令行参数的行式传参,我想在此基础上去完善一个可发送邮件的命令行工具。主要功能包括:

  • 命令行和环境变量传入相关配置
  • 支持 SSL
  • 支持抄送和密送
  • 支持基于环境变量的正文渲染
  • 支持多附件
  • 支持 HTML *
  • 支持 MarkDown *

注:「*」为待开发

使用说明

usage: smtp-send [-h] [--text TEXT]
                  [--attachments [ATTACHMENTS [ATTACHMENTS ...]]] --subject
                  SUBJECT [--recipients RECIPIENTS] [--sender SENDER]
                  [--smtp-addr SMTP_ADDR] [--smtp-port SMTP_PORT]
                  [--smtp-user SMTP_USER] [--smtp-password SMTP_PASSWORD]
                  [--ssl] [--cc CC] [--bcc BCC] [--render RENDER]
                  [--meta META]

邮件发送工具

optional arguments:
  -h, --help            show this help message and exit
  --text TEXT           正文路径
  --attachments [ATTACHMENTS [ATTACHMENTS ...]], -a [ATTACHMENTS [ATTACHMENTS ...]]
                        附件
  --subject SUBJECT, -s SUBJECT
                        主题
  --recipients RECIPIENTS
                        收件人,多个收件人间用英文逗号分隔
  --sender SENDER       发件人
  --smtp-addr SMTP_ADDR
                        SMTP 服务器地址
  --smtp-port SMTP_PORT
                        SMTP 服务器端口
  --smtp-user SMTP_USER, -u SMTP_USER
                        SMTP 用户
  --smtp-password SMTP_PASSWORD, -p SMTP_PASSWORD
                        SMTP 用户密码
  --ssl                 是否开启ssl
  --cc CC               抄送,多个收件人间用英文逗号分隔
  --bcc BCC             密送,多个收件人间用英文逗号分隔
  --render RENDER       待渲染文件
  --meta META           元数据,json格式的文件

注:

  1. --render--meta需同时指定,正文渲染才有效
  2. 如果--text被指定,则正文内容为其所指定项
  3. 除了上述两种方式,新添加了从标准输入获取正文的方式

正文渲染

  1. 待渲染文件中变量以 jinja2 的格式指定,详见官方文档

    示例:

    {{ datetime }}
    
  2. meta 文件格式:

    {
        "configmaps": {
            "datetime": "DATETIME"
        }
    }
    
  3. 呈现:

    假设设置环境变量DATETIME2019年11月23日,那么发送的正文内容就将会是

    2019年11月23日
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smtp-send-0.0.7.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

smtp_send-0.0.7-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file smtp-send-0.0.7.tar.gz.

File metadata

  • Download URL: smtp-send-0.0.7.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for smtp-send-0.0.7.tar.gz
Algorithm Hash digest
SHA256 75950a72b986cbe914ad0df0d5741a232f345555e752535af70e0080ee66dfdd
MD5 4cd6e39e0a35cddeaddcd1eb8db1b118
BLAKE2b-256 997acbb7bf798974bcdc4d0c85d0a3dd63f211356598163605dbe1e0a6b96cbc

See more details on using hashes here.

File details

Details for the file smtp_send-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: smtp_send-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for smtp_send-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f47cec7a13a521cfbfd7243d4a10eb1d83ad71407aadbe92a8f70491fed52d60
MD5 edf0caf34ba9065ed792c43520a6a134
BLAKE2b-256 c41e5432b13d5fc2a2953241099e4d68158b1118022f4405a394519bdcc1d3a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page