CMail

CMail is yet another command line e-mail sending tool, and yet another application called CMail (there are several). This CMail is primarily intended for sending scripted e-mail, but it is simple enough to be used interactively.

CMail was developed as I needed a way to generate large numbers of e-mail messages for testing mail server software and content extraction. Prior to this I had been using another freeware command line mailer which had a few small bugs I could work around, but also lacked some of the features I required, and was available for Windows only. Rather than adding to someone elses code, I decided to write my own mailer.

Features

  • IPv6.
  • TLS/SSL.
  • SMTP authentication using CRAM-MD5, PLAIN, and LOGIN.
  • Message bodies using plain text, base64, or quoted printable encoded.
  • Unlimited attachments using base64, quoted printable, UU or yEnc1 encodings.
  • Unlimited To/Cc/Bcc recipients, with aliases for each if desired.
  • Read message body from stdin.
  • Sending via SOCKS or HTTPS proxies.
  • Flexible configuration via files or the command line.
  • Written entirely in C2 - no need for .NET libraries, Java, or other BS prerequisites.
  • Runs on FreeBSD, Linux, and Windows3.
  • Free for private and commercial use.

    1 yEnc is not RFC compliant and must never be used on any public messaging system with binary content. This feature has always been, and shall forever remain, unsupported.
    2 Despite what my co-workers believe, CMail is not so named because I prefer to code in C, it is a Command line Mail application. The core application was created in a file called cmail.c, I saw no reason to change it.
    3 It probably still compiles on FreeBSD, and Linux would likely work with minimal effort, but there are plenty of other mailers on those platforms.

    Download

    CMail 0.6.1 Win32 (17 May, 2012)

    Usage

    Mandatory Options
    -host:[user:pass@]host[:port]Specifies the SMTP server to be used to deliver the message. A username and password may optionally be specified for SMTP authentication. Supported mechanisms are CRAM-MD5, PLAIN, and LOGIN (in order of preference). This setting cannot be used with -file.
    -file:filenameSpecifies a file name to write the constructed e-mail message to instead of sending it via SMTP. This setting cannot be used with -host.
    -from:address[:name]Specifies the e-mail address, and optional name, to appear in the 'From' header of the message.
    -to:address[:name]Adds a recipient, with an optional name, to appear in the 'To' field of the message. This setting may be specified multiple times.
    -cc:address[:name]Adds a recipient, with an optional name, to appear in the 'Cc' field of the message. This setting may be specified multiple times.
    -bcc:addressAdds a recipient which is not visible in the message headers. This setting may be specified multiple times.
    Content Control
    -subject:subject textSpecifies the message subject (literal string).
    -body:message bodySpecifies the message body. Note: '\\','\r','\n', and '\t' are valid escape codes.
    -body-64Use base64 encoding for the message body.
    -body-qpUse quoted-printable encoding for the message body.
    -head:header:valueAdd the specified header and header value to the message. This option may be specified multiple times. E.g. -head:X-No-Archive:Yes.
    -mimeForce use of MIME for the message body in messages having no attachments. CMail by default sends only plain text messages only when no attachments are specified.
    -smtp-transparencyWhen writing output to files, this repeats the first character on the line if it is '.'. Use this if the output files are to be sent via an SMTP server without further interpretation.
    --Read message body from stdin.
    Attachments
    -a:filenameAttach 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.
    -a64:filenameAttach the specified file using base64 encoding.
    -aqp:filenameAttach the specified file using quoted-printable encoding.
    -auu:filenameAttach the specified file using UU encoding. These attachments are encoded within the message body.
    -ayenc:filenameAttach the specified file using yEnc encoding. Note, yEnc encoding will most likely result in RFC violations in the output stream. These attachments are encoded within the message body.
    Connection Control
    -4Use IPv4.
    -6Use IPv6.
    -authtypes:type[,type...]A comma-separated list of authentication types which may be used with the upstream server. Supported values are CRAM-MD5, PLAIN, and LOGIN.
    -helo:hostnameUse the specified hostname in HELO/EHLO.
    -proxy:[user:pass@]host[:port]Connect via a proxy. Authentication is only supported for HTTPS proxies.
    -proxytype:typeSupported proxy types are SOCKS (default proxy type, default port 1080), and HTTPS (default port 8080).
    -requiretlsRequire TLS is used for mail delivery. Implies -starttls.
    -starttlsAttempt to use TLS if STARTTLS is advertised in response to EHLO.
    Debugging
    -dDebug mode, show data to and from the server.
    Command line only
    -config:filenameApply the configuration from the specified file.
    -nodefaultDo not apply settings from the default cmail.conf.
    -skipnofileBy default CMail checks attachments exist before sending the e-mail, and exits if they do not. This option disables this check. Note that e-mail will still be sent even if one or more attachments is deleted after this check, as CMail dynamically creates messages during the SMTP session.
    Configuration
    CMail applies configuration options from a default configuration file, a command line specified configuration file, and from the command line itself, in that order. Items 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 occurance will be used. I.e. You can specify a default configuration in cmail.conf, and overide settings for individual messages by specifying another config file, or via the command line.
    The default configuration is stored in ~/cmail.conf on *nix platforms, and %APPDATA%\cmail.conf on Windows.
    Configuration files must contain one setting per line, and do not include the '-' prefix.