Testing SMTP Settings With Gomtp
/ 2 min read
Table of Contents
Overview
When setting up self-hosted services, homelab servers, or CI/CD pipelines, configuring reliable email notifications is a routine requirement. However, debugging authentication failures, TLS port mismatches, or mail server rejections from inside deep application configuration panels is often painful.
gomtp is a lightweight, open-source CLI utility written in Go that validates SMTP credentials, TLS negotiation, and delivery directly from the command line (often paired with private TLS setups generated via crtforge). You can inspect the source code on the GitHub repository.
Table of Contents
Install gomtp
To install gomtp on Linux or macOS, download the latest binary directly:
sudo curl -L -o /usr/local/bin/gomtp "https://github.com/safderun/gomtp/releases/latest/download/gomtp-$(uname -s)-$(uname -m)" && \sudo chmod +x /usr/local/bin/gomtpSMTP Configuration
gomtp reads connection settings from a local configuration file.
- Create a file named
gomtp.yamlin your working directory:
vim gomtp.yamlThe configuration file must be named
gomtp.yamlby default.
- Populate the parameters for your SMTP provider:
##### Gmail App Password Example #####username: 'from@gmail.com'password: 'your-16-char-app-password'from: 'from@gmail.com'to: 'to@example.com'host: 'smtp.gmail.com'port: 587ssl: falsetls: trueauth: 'LOGIN'subject: 'SMTP Test Verification'body: | SMTP configuration test successful. Host verified: smtp.gmail.com:587Additional reference configurations for custom relays and ports are available in the example repository.
Test the Configuration
Run gomtp in the same directory where gomtp.yaml resides:
gomtp- Success Output: When credentials and network routing are correct, the binary exits cleanly:
$ gomtpEmail sent successfully!- Error Output: If the handshake fails,
gomtpsurfaces the exact upstream SMTP status code:
$ gomtp2023/12/21 11:44:33 535 5.7.8 Error: authentication failed: Invalid user or password! 1703148273-WiJ7lX77XKo0Common Homelab Use Cases
Testing with a standalone CLI binary first prevents unnecessary debugging cycles when configuring:
- Proxmox VE & Backup Server: Ensuring node notifications reach sysadmin inboxes before storage drives or backups report errors.
- Home Assistant: Validating Google or Fastmail app passwords before setting up automation notification blueprints.
- Self-Hosted Monitoring & Reverse Proxies: Verifying outbound mail relay ports (587 STARTTLS / 465 SSL) are not blocked by ISP or upstream firewall rules.