Following the Mailman: Tracking Your Email's Route
Luke Hebert
- 2 minutes read - 221 wordsWhen a script or cron job sends mail and you need to confirm what actually happened on the wire, the mail utility has a built-in verbose flag that dumps the full SMTP conversation to stderr.
Usage
mail -v <recipient>Replace <recipient> with the target address. Once you press Enter, the utility prompts for the message body. After you close the message (typically with Ctrl+D), the verbose output shows the complete SMTP handshake, including:
- The
EHLO/HELOgreeting and server response MAIL FROMandRCPT TOexchanges- The
DATAblock with the message headers and body - The final
QUITand server confirmation
Why It Helps
Most mail delivery failures are silent. The command exits with code 0, the script moves on, and the message simply never arrives. Running with -v lets you see exactly where the transaction breaks: a rejected recipient, a TLS negotiation failure, or a relay that drops the message after accepting it.
Tips
- Combine with
2>&1 | tee /tmp/mail-debug.logto capture the output for later review. - If your system uses
mailxors-nailinstead of the classicmail, the-vflag works the same way. - For
sendmaildirectly, the equivalent issendmail -v <recipient>.
Verbose output goes to stderr, not stdout. If you are piping the command output, remember to redirect stderr separately or use 2>&1.