首页 > 系统相关 >命令行非交互式发送邮件ForWindows

命令行非交互式发送邮件ForWindows

时间:2023-11-23 15:15:20浏览次数:31  
标签:body used file ## ForWindows 命令行 specified 交互式 message

2个工具

Cmail(更加推荐):https://www.inveigle.net/cmail

发现的问题:如果需要调用外部txt作为邮件的body部分,那么该文本编码必须为utf-8

下载:https://www.inveigle.net/cmail/download

最佳配置实践:https://www.inveigle.net/cmail/examples

 

Blat:https://www.blat.net/

下载:https://sourceforge.net/projects/blat/files/

 

Cmail使用说明

CMail 0.8.9 x86 (LibreSSL 3.7.3), Sep  5 2023

Use "cmail /?" for help.

## Configuration ##

CMail operates in three modes: 

(S)MTP mode is the default and is used when CMail is both constructing and sending an e-mail. 
(F)ile mode can be used to construct an e-mail message for subsequent delivery via either CMail or another application.
(P)reconstructed e-mail mode is used to send e-mails constructed using File mode or another application. 

Not all settings can be used with each mode. E.g., Settings labelled SF- apply only to SMTP and File modes. 

CMail applies configuration options from a default configuration file, a command line specified configuration file, and
from the command line itself, in that order. Settings for which multiple values can be assigned (E.g., -to) are ADDED 
from each configuration. For settings that can only be specified once, the last occurrence will be used. I.e. You can 
specify a default configuration in cmail.conf, and override settings for individual messages by specifying another 
config file, or via the command line. 

Command line parameters will undergo code page conversion, unless -clutf8 is specified. Configuration files are assumed
to be UTF-8 or ASCII. 

The default configuration is stored in %APPDATA%\cmail.conf. 

Configuration files must contain one setting per line, and do not include the '-' prefix. A '#' may be used to comment 
out a line. 

## Mandatory Options / Mode Selection ##

-host:[user:pass@]host[:port]   S-P Specifies the SMTP server to be used to deliver the message. A username and 
                                    password may optionally be specified for SMTP authentication. If user credentials 
                                    are supplied, implies -starttls if authentication is not offered prior to STARTTLS.
                                    If -oauth is specified, use the OAuth token as the password. 

-file:file                      -F- Enables (F)ile mode and specifies a filename to output the e-mail to. 

-emailfile:file                 --P Enables (P)reconstructed e-mail mode and specifies a file containing a 
                                    preconstructed e-mail for delivery via SMTP. 

-from:address[:alias]           SFP Specifies the e-mail address, with optional alias, to appear in the 'From' header 
                                    of the message. This setting is required for SMTP and File modes. In Preconstructed
                                    mode, the 'From' header will be used if this setting is omitted. 

## Recipients ##

-to:address[:alias[:DSN]]|@file SFP Adds a recipient in the 'To' field of the message or specifies the name of a file 
                                    containing a list of recipients. This setting may be specified multiple times. 

-cc:address[:alias[:DSN]]|@file SFP As above, for CC recipients. 

-bcc:address[::DSN]|@file       SFP As above, for BCC recipients. 

-reply-to:address[:alias]       SFP Specifies the e-mail address to which replies should be sent. 

The -to, -cc, and -bcc settings each add either a recipient to the message or a list of recipients from file. 

When adding individual recipients, the first parameter is required and specifies an e-mail address. The second 
parameter can be used to specify an alias, usually the name of the recipient. The alias may be quoted (using double 
quotes, escaped as necessary), although this is only required where a colon may be present in the alias. The final 
parameter specifies DSN options for the recipient, using the same format as the -dsn option documented above. E.g., 
-to:[email protected]:"Example User":DF. Where an alias is not desired (or not applicable in the case of BCC), this 
field may be left blank. E.g., -bcc:[email protected]::SFD. 

When adding recipients from file, the file name must be prefixed with '@'. E.g., -to:@filename. The file should contain
one e-mail address per line in either the form "User Alias <[email protected]>", specifying an address with an alias, or
"[email protected]" specifying only an address, both without quotes. 

When -emailfile is used, recipients will be determined by the To and Cc header fields of the preconstructed message if 
a recipient setting is not present. In all other cases, at least one recipient setting is required. 

## Content And Formatting ##

-subject:subject text           SFP Specifies the message subject (literal string). 

-body:message body              SF- Specifies the message body. Note: '\\','\r','\n', and '\t' are valid escape codes.

-body-file:file[:charset]       SF- Specifies a file containing the message body. Implies -body-qp (-body-64 may also 
                                    be specified). 

-body-64                        SF- Use base64 encoding for the message body. 

-body-qp                        SF- Use quoted-printable encoding for the message body. 

-body-html:file                 SF- Specifies a file name containing a UTF-8 encoded HTML body. Attached images can be
                                    referred to using their Content-ID if attached using -ai. 

-head:header:value              SFP Add the specified header and header value to the message. This option may be 
                                    specified multiple times. E.g., -head:X-No-Archive:Yes. 

-delhead:header                 --P Remove the specified header. This option may be specified multiple times. 

-rawhead                        --P Preserve original headers. Can be used with -head and -delhead but all other 
                                    header settings will be ignored. Non-configurable headers such as Date and 
                                    Message-ID will not be modified. 

-linelen:length                 SF- Specifies the line length for the plain text message body. The minimum and default
                                    is 78 characters. The maximum is 998 characters. 

-mime                           SF- Force use of MIME for the message body in messages without attachments. 

-dotstuff                       -F- Replace '.' with '..' at the start of lines. Use with third-party tools that do 
                                    not automatically do this when onsending via SMTP. 

-priority:n                     SFP Set the message priority to 'n', 1 = Highest, 2 = High, 4 = Low, 5 = Lowest. 

--                              SF- Read message body from stdin. 

## Attachments ##

-a:file                         SF- Attach the specified file. CMail will select base64 or quoted-printable encoding 
                                    automatically. Files containing >85% ASCII text in the first 4kB will be 
                                    quoted-printable encoded. Attachments of type message/* will use 7-bit transfer 
                                    encoding for RFC compliance. 

-a64:file                       SF- Attach the specified file using base64 encoding. Attachments of type message/* 
                                    will be identified as text/plain. 

-aqp:file                       SF- Attach the specified file using quoted-printable encoding. Attachments of type 
                                    message/* will be identified as text/plain. 

-ai:file                        SF- Attach the specified file as an inline (multipart/related) attachment, usually 
                                    used for images referenced in a HTML message body. The Content-ID is the file name,
                                    URL encoded where applicable. This value is case-sensitive. Requires -body-html. 

-auu:file                       SF- Attach the specified file using uuencoding. These attachments are encoded within 
                                    the message body. 

-awild:options:pattern[/...]    SF- Attach multiple files matching one or more patterns. See below. 

Using the -awild option, CMail supports adding multiple attachments from a source directory using patterns. Multiple 
patterns may be specified, separated by '/', and are evaluated from left to right. Patterns may include standard 
wildcard characters '*' or '?', and character sets and ranges [], and may be prefixed with a logical NOT operator '!'. 
In addition to the patterns, a number of options are available to modify the behaviour. 

Options (Case sensitive): 

H - Include hidden files 
S - Include system files 
A - Include ONLY files with the Archive attribute set 
R - Recursive (include files in subdirectories) 
C - Case sensitive matching 
U - Use uuencoding 
6 - Use base64 encoding 
Q - Use quoted-printable encoding 
I - Create inline attachments for use with -body-html 

E.g., To recursively include logs from 1970, but exclude any .tmp files, you could do the following 
-awild:R:c:\logs\1970*/!*.tmp 

## Connection Options ##

-4                              S-P Force the use of IPv4. 

-6                              S-P Force the use of IPv6. 

-authtypes:type[,type...]       S-P A comma-separated list of authentication types which may be used with the upstream
                                    server. Supported values are CRAM-MD5, PLAIN, LOGIN, OAUTHBEARER and XOAUTH2. 

-helo:hostname                  S-P Use the specified hostname in HELO/EHLO. 

-oauth                          S-P The password is an OAuth token. 

-return-path:address            S-P Specify the return path (envelope) address. 

-proxy:[user:pass@]host[:port]  S-P Connect via a proxy. Authentication is only supported for HTTPS proxies. 

-proxytype:type                 S-P Specify the type of proxy being connected to. Supported proxy types are SOCKS 
                                    (default proxy type, default port 1080), and HTTPS (default port 8080). 

-requiretls                     S-P Require TLS be used for mail delivery. Implies -starttls. 

-starttls                       S-P Attempt to use TLS if STARTTLS is advertised in response to EHLO. 

-smtps                          S-P Specifies that the port being connected to uses SMTPS (SSL/TLS without STARTTLS). 
                                    This setting changes the default port to 465. This method of securing mail transfer
                                    is deprecated, use -starttls if the target server supports that method. 

-verify                         S-P Verify certificate when connecting using SMTPS or STARTTLS is used. Note, this 
                                    setting only verifies certificates when TLS is used. Add -requiretls if TLS is 
                                    required. 

-verify-ca-path:path            S-P Specifies the CA path to use for certificate validation. Certificates should be in
                                    cert.pem or the certs subdirectory. Required if -verify is specified. 

-tls-ciphers:ciphers            S-P Set which ciphers can be used (values from LibreSSL). Values are secure, compat, 
                                    legacy and all. Default is all. 

-tls-protocols:proto[,proto...] S-P Comma-separated list of protocols that may be used (values from LibreSSL). Values 
                                    are tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3, secure and all. Default is all. 

-timeout:seconds                S-P Sets the socket timeout. 

## Delivery Status Notification (DSN) / Message Disposition Notification (MDN) ##

-dsn:options                    S-P Specifies the default DSN types to request if no DSN settings are specified for 
                                    the recipient, using the first letter of each DSN type. Acceptable values are 
                                    (S)uccess, (F)ailure, (D)elay, and (N)ever. E.g., -dsn:SFD will request a DSN for 
                                    success, failure and delay. If (N)ever is included in the list, it will take 
                                    precedence over all other values. 

-dsnid:id                       S-P Sets the envelope ID for DSN requests. If not set, a random ID will be used. 

-mdn                            SFP Request MDN (read receipt). 

## DomainKeys Identified Mail (DKIM) ##

CMail can optionally sign e-mail using DKIM signatures. DKIM is an advanced option requiring the creation of 
public/private key pairs and editing DNS records. DKIM signing is usually performed by e-mail submission servers. Refer
to RFC 6376 for additional information. 

-dkim:domain:selector:key       SFP Specifies a domain, selector and the associated key file (in PEM format) to allow 
                                    DKIM signing of e-mail. This setting can be specified multiple times, allowing for 
                                    dual signing using RSA and Ed25519 keys. When specified multiple times, the last 
                                    specified selector for the sending (or default) domain and key type will be used. 

-dkim-default:domain            SFP The default domain and associated selector will be used if no specific -dkim 
                                    option matches the sender's from domain. 

-dkim-algo:algorithm            SFP Use the specified DKIM signing algorithm. Supported values are ed25519-sha256, 
                                    rsa-sha256, rsa-sha1, best (default) and all. This setting may be specified 
                                    multiple times. The best setting follows best practice and will attempt to sign 
                                    e-mail using both ed25519-sha256 and rsa-sha256, where suitable keys have been 
                                    provided. 

-dkim-canon:canon               SFP Specifies the DKIM canonical form (simple or relaxed) for the message headers and 
                                    body. Supported values are s/s (default), s/r, r/s and r/r. 

-no-dkim                        SFP Disable DKIM signing of the message. This setting allows you to ignore any DKIM 
                                    records in the configuration and send via hosts that will alter messages or sign on
                                    behalf of your domain. 

## Debugging ##

-d                              S-P Debug mode. Show data to and from the server. Passwords are not logged. 

-dd                             S-P Extended debug mode. As above but adds socket and TLS debugging information. 
                                    Passwords are not logged. 

## Command Line Only ##

-body-literal                   SF- Do not convert line breaks to CRLF on a message body specified using -body-file. 
                                    The body will be quoted printable encoded (-body-64 may also be specified). 

-clutf8                         SFP Assume command line parameters are UTF-8. Disables code page conversion and may be
                                    necessary when calling CMail from within other applications. 

-encryptpass:password           --- Output an encrypted version of the specified password and exit. The encrypted 
                                    password can be used with the -host option. Encryption only provides protection 
                                    against casual password observation. 

-bindpass                       --- Encrypt password using a host-specific key. 

-config:file                    SFP Apply the configuration from the specified file. 

-nodefault                      SFP Do not apply settings from the default cmail.conf. 

-skipnofile                     SF- Do not check attachments exist before constructing e-mail. 

-results:filename               S-- Output e-mail delivery details to a JSON file. Use '-' to output to stdout. 

 

标签:body,used,file,##,ForWindows,命令行,specified,交互式,message
From: https://www.cnblogs.com/airoot/p/17851567.html

相关文章

  • change windows cmd prompt 修改windows命令行提示符
    通过修改环境变量控制cmd提示符。 refcmd-HowdoIchangethecommand-linepromptinWindows?-StackOverflowhttps://stackoverflow.com/questions/12028372/how-do-i-change-the-command-line-prompt-in-windowsAbetterPROMPTforCMD.EXEorCoolPromptEnv......
  • Tmux 终端命令行介绍
    一、 命令介绍: Tmux("TerminalMultiplexer"的简称),是一款优秀的终端复用软件,类似 GNUscreen,但比screen更出色。tmux来自于OpenBSD,采用BSD授权。使用它最直观的好处就是,通过一个终端登录远程主机并运行tmux后,在其中可以开启多个控制台而无需再“浪费”多余的终端来连接......
  • 命令行方式启动nginx
    果nginx在d:/software/nginx目录下,那么命令行启动方式是:1、进入d:/software/nginx目录下复制1cdd:/software/nginx2、启动nginx复制1startnginx3、如果需要关闭nginx,则执行如下命令:复制1nginx-sstop......
  • 无涯教程-Ruby - Ruby命令行选项函数
    Ruby通常以以下方式从命令行运行-$ruby[options][.][programfile][arguments...]可以使用以下任何选项来调用解释器,以控制解释器的环境和行为。Sr.No.Option&Remark1-a与-n或-p一起使用以分割每行。检查-n和-p选项。2-c仅检查语法,而不执行程序。3......
  • ng config -g cli.packageManager npm 命令行的使用
    ngconfig-gcli.packageManagernpm这条命令是在AngularCLI环境下执行的,它的主要目的是全局设置AngularCLI使用的包管理器。这里,-g代表全局设置,cli.packageManager是你要配置的属性,npm是你要设置的值。这条命令将会把AngularCLI的包管理器设置为npm,这意味着在你使......
  • mongoDB命令行交互
    命令行交互命令行交互一般是学习数据库的第一步,不过这些命令在后续用的比较少,了解即可。角色命令创建角色useadmindb.createUser({"user":"root","pwd":passwordPrompt(),"roles":[{role:"role",db:"<database>"}|"root"]})校验......
  • 命令行参数编程
    1. 新程序开始时典型的栈结构                        2. 命令行参数规范1.短选项参数规范:(1)由选项、选项值、操作数组成(注意操作数的位置不一定)例:①gcctest-otest.out......
  • linux下使用命令行工具alidrive上传文件到阿里云盘
    linux下使用命令行工具alidrive上传文件到阿里云盘下载alidrive,并解压wgethttps://github.com/aoaostar/alidrive-uploader/releases/download/v2.2.1/alidrive_uploader_v2.2.1_linux_amd64.tar.gztar-xvfalidrive_uploader_v2.2.1_linux_amd64.tar.gz修改配置文件重......
  • python windows环境自己的程序实现命令行补全/使用pyreadline实现(目前已知唯一方法,对p
    1.环境前提注意事项python3版本最好是3.10以下(理论上),最新版可能会有问题,本文使用python3.7.2版本本文环境是用pipenv加pyenv虚拟环境实现的,想了解的去我的主页搜素相关博文安装pyreadline(全平台通用win/linux)pipinstallpyreadline版本问题报错请参考:https://blog.csdn......
  • verilog 命令行输入参数
    方便进行配置参数的多次遍历tb的.v文件中//getRG_huffmantypefromsimvinshellinitialbeginif($value$plusargs("RG_type=%d",RG_type))begin RG_HuffmanType=RG_type;endelseRG_HuffmanType=5'b0000......