Synopsis

perch mail send [OPTIONS]

Description

Compose a MIME message and submit it through SMTP. Text and HTML bodies are combined as multipart/alternative; attachments wrap the result in multipart/mixed.

Bodies come from –body/–body-file and –html-body/–html-file, or stdin when it is not a terminal. Attachments are base64 encoded and content types are detected from the file extension or contents.

Notes

  • Bodies are quoted-printable unless –8bitmime is set; attachments are base64.
  • SMTPUTF8 is detected from non-ASCII envelope addresses and extra headers; force it with –smtputf8.
  • Bcc recipients are envelope-only and never appear in headers.
  • SIZE is sent automatically and checked against the server’s advertised limit.

Options

OptionDescription
--username, -u <value>account username (env PERCH_IMAP_USER)
--password <value>account password (prefer PERCH_IMAP_PASSWORD or –password-file)
--password-file <value>read the account password from a file
--password-stdinread the account password from stdin
--timeout <value>connection timeout (default: 30s)
--config <value>configuration file (default: ~/.config/perch/perch.yaml)
--from <value>sender address (default: –username)
--to <value>...recipient address or list; repeatable
--cc <value>...Cc recipient address or list; repeatable
--bcc <value>...Bcc recipient address or list; repeatable
--reply-to <value>...Reply-To address or list; repeatable
--subject, -s <value>message subject
--body <value>plain-text body
--body-file <value>read the plain-text body from a file (use - for stdin)
--html-body <value>HTML body
--html-file <value>read the HTML body from a file (use - for stdin)
--attach, -a <value>...attach a file; repeatable
--header, -H <value>...add an extra header (Name: Value); repeatable
--in-reply-to <value>Message-ID being replied to
--references <value>space-separated Message-IDs for References
--8bitmimesend UTF-8 text with BODY=8BITMIME
--smtputf8force SMTPUTF8 (usually detected automatically)
--dry-run, -nwrite the composed message to stdout without sending
--verbose, -vprint SMTP capabilities and delivery details to stderr
--smtp-server, -S <value>SMTP submission server (smtps://host, smtp://host, or host[:port]); defaults from –config
--smtp-plaintextconnect to SMTP without TLS (use only on trusted networks)
--smtp-starttlsrequire STARTTLS for SMTP
--smtp-implicit-tlsuse implicit TLS for SMTP (usually port 465)
--smtp-insecureskip SMTP TLS certificate verification
--smtp-ca-file <value>PEM CA bundle used to verify the SMTP server certificate
--help, -hshow help

Examples

perch mail send --from you@example.com --to alice@example.com \
  --subject Hello --body 'Hi Alice'

echo 'Body from stdin' | perch mail send --from you@example.com \
  --to alice@example.com --subject Hello

perch mail send --from you@example.com --to alice@example.com \
  --subject Report --body-file message.txt --html-file message.html \
  --attach report.pdf

perch mail send ... --dry-run > message.eml

Environment

VariablePurpose
PERCH_IMAP_USERdefault account username and sender
PERCH_IMAP_PASSWORDaccount password

See also