Skip to main content

Send a formatted email from the command line

Project description

Send Mail Via Python (smvp)

PyPI version Python versions License Status PyPI downloads


smvp logo

The smvp utility reads a file, uses its contents as the body of an email, and sends it to a specified recipient. The input file can be a text file with ANSI color codes, HTML, or plain text. The resulting message is sent as a multipart MIME email that renders properly in both plain text and HTML. The --content-type option can auto-detect the input type or force it to be handled as plain text or HTML.

Note: The file itself is not sent as an attachment; instead, the contents of the file are put into the body of the email.

Compatibility

The smvp runtime is supported on Windows and Linux.

Project tooling remains Linux-only. That includes the just recipes, the Bash scripts in scripts/, the release workflow, and the cron examples below.

Use Case

There are several use cases, but smvp was developed for two primary purposes:

  1. Configuring postfix and sendmail can be more setup than a small script needs.
  2. Cron scripts often need to email status information and the contents of various log files. Some of the files contain ANSI escape sequences for terminal colors. The smvp utility converts those ANSI escape sequences into styled HTML, so the resulting emails are nicely formatted. You could set $MAILTO in your crontab, but you would not get proper handling of ANSI escape sequences, and you would still have the problem mentioned in item 1.

Installation

Use your preferred Python package installer for command line tools, for example:

pipx install smvp

or

uv tool install smvp

or

python -m venv .venv

# Linux / macOS
source .venv/bin/activate

# Windows PowerShell
.venv\Scripts\Activate.ps1

# Windows Command Prompt
.venv\Scripts\activate.bat

python -m pip install smvp

Requirements

SMTP Environment Variables

Set the following environment variables in the shell you are using before running smvp.

Linux / macOS shells:

export SMVP_USER="<your email>"    # e.g. "myemail@gmail.com"
export SMVP_TOKEN="<your token>"   # e.g. "<gmail app password>"
export SMVP_SERVER="<smtp server>" # e.g. "smtp.gmail.com"

Windows PowerShell:

$env:SMVP_USER = "<your email>"
$env:SMVP_TOKEN = "<your token>"
$env:SMVP_SERVER = "<smtp server>"

Windows Command Prompt:

set SMVP_USER=<your email>
set SMVP_TOKEN=<your token>
set SMVP_SERVER=<smtp server>

If you want these variables to persist across sessions, add them to your shell profile or your Windows user environment settings.


Linux automation note:

Tip: If you're using cron and sending mail with smvp from within a script, make sure to include the environment variables at the top of your crontab so your scripts will have access to them during execution. Also include a line in your script that exports the directory where your Python tool installer places executables. For example, if you're using uv on Ubuntu, you could put something like this near the top of your bash script:

# Setup PATH export so the script can find installed Python tools
export PATH="$PATH:/home/<yourhome>/.local/bin"

SMTP Server

The SMVP_SERVER you select must support secure TLS connections on port 587. Check the SMTP settings for your email provider. This is the default TLS port on Gmail, so if you are using your Gmail account to send email, this requirement is usually already satisfied.

Styling

smvp offers custom font and font size options for your email. The default font for formatted HTML email is Courier New, 12px. Beyond the default, you can choose any font size from 2px up to and including 100px, from the following font families:

"Andale Mono", "Arial", "Brush Script MT", "Comic Sans MS",
"Courier New", "Garamond", "Georgia", "Helvetica", "Impact",
"Luminari", "Monaco", "Tahoma", "Times New Roman", "Trebuchet MS",
"Verdana", "fantasy", "monospace", "sans-serif", "serif"

Note: Not every font will render properly on every device. When in doubt, fonts like: "monospace", "sans-serif", "fantasy", and "serif" are pretty safe. You may just have to try a few options to land on the right one for your use case.

Content Type

By default, smvp uses --content-type auto, which inspects the input and decides whether to treat it as plain text or HTML. You can override that behavior when needed:

auto  Auto-detect whether the input should be treated as text or HTML
text  Always treat the input as plain text, including HTML-like content
html  Always treat the input as HTML

This is useful when the input contains angle brackets that should be sent literally, or when you want to force HTML rendering for a file that would not otherwise be detected as HTML.

Usage

usage: smvp [-h] [-c {auto,text,html}] [-f FONT_FAMILY] [-s FONT_SIZE] [-v] recipient subject file

For example:

smvp friend@gmail.com "Hello, Friend" ~/logfile.txt -f "Trebuchet MS" -s 14

On Windows, the same command works after installation. The only difference is the path style, for example:

smvp friend@gmail.com "Hello, Friend" .\logfile.txt -f "Trebuchet MS" -s 14

Force plain-text handling for HTML-like input:

smvp friend@gmail.com "Raw Markup" ./snippet.txt --content-type text

Force HTML handling:

smvp friend@gmail.com "Rendered Markup" ./fragment.txt --content-type html

For more details, run:

smvp -h

The package also supports Python module execution:

python -m smvp -h

For maintainers, the installed smvp console command is declared in pyproject.toml and points to smvp.app:main. The runnable module entry point lives in src/smvp/__main__.py, and the real CLI parser and dispatch code lives in src/smvp/app.py.

Maintainer Workflow

Run dependency upgrades from a clean worktree:

just upgrade

The command calls scripts/upgrade_dependencies.sh, checks for outdated first-order dependencies declared in pyproject.toml, upgrades only those packages, and creates one local deps: Dependency Upgrades commit when direct locked versions changed. The commit body lists each direct dependency version change as old -> new. It does not push; review the local commit before pushing manually.

If only transitive locked dependencies changed, no commit is created and the dependency files are restored. Changelog generation groups deps: commits as Dependency Upgrades. Deprecated entries should use deprecate: or deprecated:.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smvp-0.4.4.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smvp-0.4.4-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file smvp-0.4.4.tar.gz.

File metadata

  • Download URL: smvp-0.4.4.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smvp-0.4.4.tar.gz
Algorithm Hash digest
SHA256 546cedb7b72f5575e22d62c371526ec404afd8dabcdf7aa0e4e5f39f442f795a
MD5 dc9f1816749f1f31b4e2654b3d4468c3
BLAKE2b-256 5f57d3f206590b746aeaf0b3523a4a6cac4011ad0f1306e4f235745ca0befaae

See more details on using hashes here.

File details

Details for the file smvp-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: smvp-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smvp-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 08c10f422fcf21932375be69b432a3cdcf66b983c5204996313519a7f5cb9879
MD5 77439b9352ddcd755adc7f1708a7180d
BLAKE2b-256 6f43708a435012eaffbd11ef1faf8603c718dab72aa99af14143ef305427d409

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page