sendsmtp
CLI SMTP client in pure Python. No dependencies, one command: it builds a UTF-8 text/plain message — text/html with --html, multipart/mixed once files are attached — and hands it to an SMTP server.
Installation
python3 -m pip install --user --upgrade sendsmtp
Requires Python 3.11 or newer.
Quick start
$ sendsmtp smtp.example.com me@example.com you@example.com -s "Hi" -m "Hello!"
Message successfully sent.
Synopsis
sendsmtp [-h] [-m MESSAGE] [-i INPUT] [--html] [-p PORT] [-u USERNAME]
[--password PASSWORD] [-t | --starttls] [--allow-untrusted]
[-c CC] [-b BCC] [-s SUBJECT] [-a PATH] [-v]
HOST FROM TO
Arguments
HOST
Hostname or IP address of the SMTP server to connect to.
$ sendsmtp smtp.example.com me@example.com you@example.com -m "hi"
FROM
Sender address, used both as the SMTP envelope sender (MAIL FROM) and as the From: header.
TO
Recipient address, or several addresses separated by commas — no spaces around the commas.
$ sendsmtp smtp.example.com me@example.com "a@example.com,b@example.com" -m "hi"
Options
-m MESSAGE, --message MESSAGE
Message body, given inline.
$ sendsmtp smtp.example.com me@example.com you@example.com -m "Deploy finished."
-i INPUT, --input INPUT
Path to a file to read the message body from. Takes precedence over --message. If the path is not an existing file the option is ignored and the body is taken from --message or from stdin instead.
$ sendsmtp smtp.example.com me@example.com you@example.com -i report.txt
If neither --message nor --input is given, the body is read from stdin. Piped input is read to EOF:
$ dmesg | tail -n 20 | sendsmtp smtp.example.com me@example.com you@example.com -s "dmesg"
When stdin is a terminal, sendsmtp prompts and reads lines until a line containing only EOF:
$ sendsmtp smtp.example.com me@example.com you@example.com
Please, provide message contents. Type 'EOF' for end.
First line.
Second line.
EOF
Message successfully sent.
--html
Send the body as text/html instead of text/plain. The body itself is taken from --message, --input or stdin as usual — the flag only changes the content type, nothing is escaped or wrapped.
$ sendsmtp smtp.example.com me@example.com you@example.com \
-s "Report" -i report.html --html
No plain-text alternative part is generated: the message is a single text/html part, so clients that refuse HTML show it as markup.
-s SUBJECT, --subject SUBJECT
Message subject.
$ sendsmtp smtp.example.com me@example.com you@example.com -s "Nightly build" -m "green"
If --subject is not given and the body starts with a Subject: line, that line is stripped from the body and used as the subject:
$ printf 'Subject: From the body\n\nBody text.\n' \
| sendsmtp smtp.example.com me@example.com you@example.com
-p PORT, --port PORT
SMTP port. Defaults depend on the security mode: 25 for plain, 587 with --starttls, 465 with --tls.
$ sendsmtp smtp.example.com me@example.com you@example.com -p 2525 -m "hi"
-t, --tls
Use implicit TLS — the connection is encrypted from the first byte (SMTPS, port 465 by default). Mutually exclusive with --starttls.
$ sendsmtp smtp.example.com me@example.com you@example.com -t -u me@example.com -m "hi"
--starttls
Connect in plain text and upgrade the connection with the STARTTLS extension (port 587 by default). Mutually exclusive with --tls.
$ sendsmtp smtp.example.com me@example.com you@example.com --starttls -u me@example.com -m "hi"
--allow-untrusted
Skip TLS certificate verification: the server certificate is not checked against the trust store and its hostname is not matched. Only affects --tls and --starttls. Insecure — anyone on the path can impersonate the server — so use it only for servers with a self-signed certificate you cannot add to the system trust store.
$ sendsmtp smtp.internal me@example.com you@example.com --starttls --allow-untrusted -m "hi"
-u USERNAME, --username USERNAME
Username for SMTP authentication. Without it no AUTH is attempted.
--password PASSWORD
Password for SMTP authentication. If --username is given but --password is not, the password is asked for interactively and is not echoed — preferable, since command lines are visible to other processes and land in the shell history.
$ sendsmtp smtp.example.com me@example.com you@example.com --starttls -u me@example.com -m "hi"
me@example.com's passwd:
Authentication failures abort the run; the message is not sent.
-c CC, --cc CC
Carbon-copy recipient(s), comma separated. The addresses appear in the CC: header and receive the message.
$ sendsmtp smtp.example.com me@example.com you@example.com -c "boss@example.com" -m "hi"
-b BCC, --bcc BCC
Blind carbon-copy recipient(s), comma separated. They receive the message but are not listed in any header.
$ sendsmtp smtp.example.com me@example.com you@example.com -b "archive@example.com" -m "hi"
-a PATH, --attach PATH
Attach a file to the message. Repeat the option once per file; the message then becomes multipart/mixed with the body as its first part.
$ sendsmtp smtp.example.com me@example.com you@example.com \
-s "Nightly report" -m "See attached." -a report.pdf -a data.csv
The content type is guessed from the file name, falling back to application/octet-stream. A missing path is reported before the SMTP connection is opened, so nothing is sent and no password is asked for.
-v, --verbose
Print the SMTP dialog to stderr, report the connection and authentication steps, list the addresses the message was delivered to, and, on failure, let the full stacktrace through instead of a one-line error.
$ sendsmtp smtp.example.com me@example.com you@example.com -m "hi" -v
Connected to smtp.example.com:25 (plain).
send: 'ehlo host.example.com\r\n'
reply: b'250 smtp.example.com\r\n'
...
Message successfully sent to you@example.com
-h, --help
Print the usage summary and exit.
Headers
The generated message carries From:, To:, Subject:, CC: (only with --cc) and X-Mailer: sendsmtp.
Exit codes
Code |
Meaning |
|---|---|
0 |
Message accepted by the server for every recipient. |
1 |
Error, or at least one recipient was refused. |
130 |
Interrupted with Ctrl-C. |
On failure only a single-line error is printed; pass --verbose to get the SMTP dialog and the full stacktrace.
License
MIT. See LICENSE.
Metadata
Release files for sendsmtp 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sendsmtp-2.0.1.tar.gz | 73.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sendsmtp-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.9 kB
Release files / sendsmtp-2.0.1.tar.gz
| Download URL | sendsmtp-2.0.1.tar.gz |
|---|---|
| Size | 73.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5da722afbf769d207f0f43cf50fca95da83292dd75ba698f838ddfdd1bfdc6e2
|
|
BLAKE2b-256 checksum How to use checksums |
ca1bd304158edaa58488a613ac3b08c0a41e61d12a5eb4b586db7837240e2b6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency logRelease files / sendsmtp-2.0.1-py3-none-any.whl
| Download URL | sendsmtp-2.0.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
511f8f510772c5d5c5317713d123044c0199238cf2c436ba4cdd2d39680087ab
|
|
BLAKE2b-256 checksum How to use checksums |
6ee1043444f06cad084f10b01db13b57b20dd2794f4e8bb0bddf03e74a8eb087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency log