TECH / Windows 2 min read

How to Send Email from Windows Command Line via Gmail Using sendEmail (and App Passwords)

NEMCD Author
Published Jun 30, 2016 · 2 min

Years ago I wrote about sending automated Gmail alerts from the Windows command line using Blat paired with stunnel. Later, when I needed simple reboot notifications on another Windows server, I wanted something cleaner – a single lightweight tool with no background proxy wrapper.

sendEmail command-line SMTP utility for Windows

That tool turned out to be sendEmail by Brandon Zehm – a compact command-line SMTP client with native TLS support and crystal-clear flags.

Command Syntax and Working Gmail Example

Every option passes right on the command line, making it effortless to drop into .bat files and Windows Task Scheduler:

sendEmail command-line options and syntax reference

Here is a complete one-liner for sending a short alert through Gmail SMTP (port 587 with STARTTLS):

sendEmail -o tls=yes -f [email protected] -t [email protected] -s smtp.gmail.com:587 -xu [email protected] -xp APP_PASSWORD -u "DS19 reboot!" -m "Hello, DS19 reboot"

If your subject or message body uses non-ASCII characters, append the UTF-8 charset option (and save your batch file in UTF-8 without BOM):

-o message-charset=utf-8

For quick one-line server notifications, plain English text is still the safest bet across every mail client. You can download the final release archive (v1.56) here: sendEmail-v156.zip.

Important Gmail Update: Use an App Password

Why your regular Gmail password fails now: Google retired “Less secure app access” using standard account passwords. To authenticate SMTP scripts against smtp.gmail.com:587 today, enable 2-Step Verification on your Google account and generate a 16-character App Password – paste that into the -xp flag.

Modern Zero-Install Alternative Built into Windows

Because sendEmail v1.56 dates back to 2009, on modern Windows 10, Windows 11, and Server editions you can skip third-party binaries entirely and use Windows’ built-in curl.exe (with modern TLS 1.2/1.3 over SMTPS port 465):

curl --ssl-reqd --url "smtps://smtp.gmail.com:465" --user "[email protected]:APP_PASSWORD" --mail-from "[email protected]" --mail-rcpt "[email protected]" --upload-file mail.txt

Even so, for legacy servers and existing batch workflows, sendEmail remains one of the simplest one-line mail senders ever written.

Related posts:

Leave a Comment