NAME

mailmake - Build and send RFC 2822 / MIME email from the command line

SYNOPSIS

# Plain-text message
mailmake --from alice@example.com --to bob@example.com \
         --subject "Hello" --plain "Hi Bob." \
         --smtp-host mail.example.com

# HTML + plain text (alternative) with attachment
mailmake --from alice@example.com --to bob@example.com \
         --subject "Report" \
         --plain-file body.txt --html-file body.html \
         --attach report.pdf \
         --smtp-host mail.example.com --smtp-port 587 --smtp-starttls \
         --smtp-user alice@example.com --smtp-password secret

# Print the raw RFC 2822 message instead of sending
mailmake --from alice@example.com --to bob@example.com \
         --subject "Test" --plain "Test" --print

# OpenPGP detached signature
mailmake --from alice@example.com --to bob@example.com \
         --subject "Signed" --plain "Signed message." \
         --gpg-sign --gpg-key-id FINGERPRINT \
         --smtp-host mail.example.com

# OpenPGP sign + encrypt
mailmake --from alice@example.com --to bob@example.com \
         --subject "Secret" --plain "Encrypted message." \
         --gpg-sign --gpg-encrypt \
         --gpg-key-id FINGERPRINT --gpg-passphrase secret \
         --smtp-host mail.example.com

# S/MIME signature
mailmake --from alice@example.com --to bob@example.com \
         --subject "Signed" --plain "Signed message." \
         --smime-sign \
         --smime-cert /path/to/my.cert.pem \
         --smime-key  /path/to/my.key.pem \
         --smime-ca-cert /path/to/ca.crt \
         --smtp-host mail.example.com

# S/MIME sign + encrypt
mailmake --from alice@example.com --to bob@example.com \
         --subject "Secret" --plain "Encrypted." \
         --smime-sign --smime-encrypt \
         --smime-cert /path/to/my.cert.pem \
         --smime-key  /path/to/my.key.pem \
         --smime-recipient-cert /path/to/recipient.cert.pem \
         --smtp-host mail.example.com

DESCRIPTION

mailmake is a CLI powered by Mail::Make. It assembles RFC 2822 / MIME messages, optionally signs and/or encrypts them with OpenPGP or S/MIME, and delivers them via SMTP (plain, STARTTLS, or SMTPS).

Alternatively, pass --print to write the raw RFC 2822 message to STDOUT instead of delivering it - useful for piping or debugging.

OPTIONS

Envelope / Headers

--from, -f ADDRESS

Sender address (required). Example: Alice <alice@example.com>

--to, -t ADDRESS [ADDRESS ...]

One or more recipient addresses (required, repeatable).

--cc ADDRESS [ADDRESS ...]

Carbon-copy addresses (repeatable).

--bcc ADDRESS [ADDRESS ...]

Blind carbon-copy addresses (repeatable).

--reply-to ADDRESS

Reply-To header value.

--sender ADDRESS

Sender header value (when the submitter differs from the author).

--subject, -s TEXT

Message subject. Non-ASCII characters are encoded automatically (RFC 2047).

--header Name:Value

Add an arbitrary header. Repeatable. Example: --header "X-Mailer:mailmake"

Body

At least one of --plain, --plain-file, --html, or --html-file should be supplied. When both plain and HTML bodies are given, a multipart/alternative structure is built automatically. Adding attachments wraps everything in multipart/mixed.

--plain TEXT

Plain-text body (literal string).

--plain-file FILE

Plain-text body loaded from a file.

--html TEXT

HTML body (literal string).

--html-file FILE

HTML body loaded from a file.

--attach FILE [FILE ...]

File attachment(s), added as multipart/mixed parts (repeatable).

--attach-inline FILE [FILE ...]

Inline attachment(s), added as multipart/related parts, intended for embedding images in HTML (repeatable).

--charset NAME

Character set for text bodies. Default: UTF-8.

Output

--print

Write the assembled RFC 2822 message to STDOUT instead of delivering it.

Useful for piping to sendmail, inspecting the message, or testing.

SMTP Delivery

--smtp-host, -H HOST

SMTP server hostname or IP address.

--smtp-port, -P PORT

SMTP port. Defaults to 25 (plain), 587 (STARTTLS), or 465 (SMTPS/TLS).

--smtp-user, -U USERNAME

Login name for SMTP authentication (SASL PLAIN/LOGIN).

Requires Authen::SASL.

--smtp-password PASSWORD

Password for SMTP authentication.

--smtp-starttls

Upgrade the connection to TLS using STARTTLS (typically port 587).

--smtp-tls

Use direct TLS from the start (SMTPS, typically port 465).

--smtp-timeout SECONDS

Connection and command timeout. Default: 30.

OpenPGP (requires gpg / gpg2 and IPC::Run)

OpenPGP options cannot be combined with S/MIME options.

--gpg-sign

Sign the message (RFC 3156 multipart/signed with detached ASCII signature).

--gpg-encrypt

Encrypt the message (RFC 3156 multipart/encrypted).

--gpg-sign and --gpg-encrypt may be combined for sign-then-encrypt.

--gpg-key-id FINGERPRINT

Signing key fingerprint or ID (required when --gpg-sign is used).

--gpg-passphrase PASSPHRASE

Passphrase to unlock the secret key. When omitted, gpg-agent is expected to handle passphrase prompting.

--gpg-recipients ADDRESS [ADDRESS ...]

Recipient key IDs or e-mail addresses for encryption. Defaults to --to when not specified.

--gpg-digest ALGORITHM

Hash algorithm for signatures. Default: SHA256.

Valid values: SHA256, SHA384, SHA512, SHA1.

--gpg-bin PATH

Full path to the gpg executable. Defaults to searching gpg2 then gpg in PATH.

--gpg-keyserver URL

Keyserver URL for auto-fetching recipient keys. Only consulted when --gpg-autofetch is set. Example: keys.openpgp.org

--gpg-autofetch

Fetch missing recipient public keys from --gpg-keyserver before encrypting.

S/MIME (requires Crypt::SMIME)

S/MIME options cannot be combined with OpenPGP options.

--smime-sign

Sign the message (RFC 5751 multipart/signed with detached signature).

--smime-encrypt

Encrypt the message (RFC 5751 application/pkcs7-mime).

--smime-sign and --smime-encrypt may be combined for sign-then-encrypt.

--smime-cert FILE

Signer certificate in PEM format (required when --smime-sign is used).

--smime-key FILE

Signer private key in PEM format (required when --smime-sign is used).

--smime-key-password PASSPHRASE

Passphrase for an encrypted private key.

--smime-ca-cert FILE

CA certificate in PEM format, included for chain verification.

--smime-recipient-cert FILE [FILE ...]

Recipient certificate(s) in PEM format (required when --smime-encrypt is used). Repeatable for multi-recipient encryption.

General

--quiet, -q

Suppress informational output.

--verbose N, -v

Increase verbosity level (integer).

--debug N, -d

Enable debug output (integer level).

--help, -h

Print this help and exit.

--man

Print the full manual page.

-v

Print the version and exit.

EXIT CODES

  • 0

    Message delivered (or printed) successfully.

  • 1

    Delivery failed or a usage error occurred.

  • 2

    Usage error (bad arguments).

SEE ALSO

Mail::Make, Mail::Make::GPG, Mail::Make::SMIME

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.