How to Send Email From Windows Command Line With Attachment
Email remains one of the most powerful tools for both personal and professional communication. Beyond staying in touch with friends and family, it’s essential for real-time notifications and alerts. Whether you need to know when your server goes down via a monitoring service like Pingdom or require automated status updates from third-party backup software, email notifications keep you informed at every step.
If you’re writing a batch file and want to automatically send an email upon completion—or using a third-party tool that lacks built-in email alerts—a command-line email-sending tool for Windows is your go-to solution. This guide explores seven robust utilities that simplify sending emails via the command line.
How to Use These Tools
Each tool example below uses a sample command line for sending an email through Gmail. Before running any commands, update these parameters accordingly:
[email protected]
– Replace with your full Gmail address[email protected]
– Replace with the recipient’s email addressYourGmailPassword
– Replace with your Gmail passwordsubject
– The email subject (use double quotes if it contains spaces, e.g.,"This is a long subject"
)message
– The email body (also use double quotes if it contains spaces)
1. SwithMail
Among command-line email tools, SwithMail stands out due to its intuitive configuration GUI, minimizing errors in command syntax. You can even test your email settings directly before execution.

SwithMail supports attachments, CC, BCC, wildcard attachments for log files, and error code returns.
Command example for sending an email via Gmail:
shCopyEditSwithMail.exe /s /from [email protected] /pass YourGmailPassword /server smtp.gmail.com /p 587 /SSL /to [email protected] /sub subject /b message
2. CMail
If proxy support is essential (SOCKS or HTTPS-based proxies), CMail is a great choice. It also supports wildcard attachments and delivery status notifications.
Gmail command example:
shCopyEditCMail.exe -secureport -host:[email protected]:[email protected]:465 -from:[email protected] -to:[email protected] -subject:subject -body:message
3. SendSMTP
SendSMTP offers both an interactive GUI and a powerful command-line tool. Beginners can configure it via GUI, while advanced users benefit from direct command-line execution.

Gmail command example:
shCopyEditSendSMTP.exe /nos /host smtp.gmail.com /port 587 /auth 2 /userid [email protected] /pass YourGmailPassword /from [email protected] /to [email protected] /subject subject /body message
4. mailsend
mailsend is a simple SMTP command-line tool for Windows and Linux. While it lacks a GUI or encryption features, it provides a useful -info
option to display SMTP server details.

Gmail command example:
shCopyEditmailsend1.17b15.exe -t [email protected] -f [email protected] -ssl -port 465 -auth -smtp smtp.gmail.com -sub subject -M message -user [email protected] -pass YourGmailPassword
5. Send-It-Quiet
Send-It-Quiet is a lightweight SMTP mailer (14KB) built on the .NET Framework. It supports custom registry parameters and return values via ERRORLEVEL
.
Gmail command example:
shCopyEditsenditquiet.exe -s smtp.gmail.com -port 587 -u [email protected] -protocol ssl -p YourGmailPassword -f [email protected] -t [email protected] -subject subject -body message
6. SendEmail
Despite its last update in 2009, SendEmail still supports TLS for Gmail SMTP and doesn’t require Perl installation on Windows.
Gmail command example:
shCopyEditsendEmail.exe -o tls=yes -f [email protected] -t [email protected] -s smtp.gmail.com:587 -xu [email protected] -xp YourGmailPassword -u subject -m message
7. PowerShell
Windows PowerShell provides a built-in way to send emails via Gmail SMTP without third-party tools.

Run the PowerShell script:
shCopyEditPowershell.exe -executionpolicy remotesigned -File C:\Users\Raymond\sendemail.ps1
Final Notes
Older tools such as Blat lack SSL support and are omitted from this list. Tools like Bmail and XmlSendmail are outdated and do not support Gmail SMTP authentication.
By choosing the right command-line email tool for your needs, you can easily automate email notifications for various tasks—whether for monitoring servers, sending logs, or integrating alerts into scripts.
Sendemail still does the job for me. Thank you for your listing.
hello I am using below script in powershell but getting error:
$EmailFrom = “from_email_id”
$EmailTo = “to_email_id”
$Subject = “Subject”
$Body = “Hello User”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“emailid”, “password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
error:
Exception calling “Send” with “4” argument(s): “The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.0 Authentication Required. Learn more at”
At line:1 char:1
+ $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SmtpException
This is such a nice find! I tried SwithMail, SendSMTP and Powershell, but loved SwithMail more because it’s fairly up-to-date compared to SendSMTP and it offers password obfuscation . They all worked beautifully with Gmail using an app-specific password. Powershell offers a fantastic native solution if use of third-party tools is not preferable. Thanks for this extremely handy listing. Some free backup programs lock the email alert feature, but allow running of scripts/programs before and/or after backup jobs are executed. These solutions will come in handy for such cases. I’m using this with Internet Download Manager to alert me when downloads in a queue are complete.
A feature I’m looking for is the ability to pipe output from a command into the command line mail sender as it’s body or be able to specify a text file to use as the body. For example, this feature would be useful for running a powershell script and piping it’s output directly into an email. Do any of these utilities have this capability?
Yes. CMail supports both.
I have programmed a small tool that also sends mails via cmd / batch. You can use a gui to create the command. It supports SSL, authentication and sending via the OWA interface of the Exchange Server.
Link: chefsender.com
On a tangent, Davmail is a local proxy that converts an owa (no smtp/imap) email address into a usable connection for those sweet, sweet Thunderbird plugins. Or opera mail m2. Or TheBat. Or HERMES. Or Eudora. Or Em Client.
Hi,
Dipisoft SendMail (freeware) software is another email sending tool for Windows which has a graphical interface but can also be used in command line mode.
It allows you to send attachments, can interface with the ActiveDirectory in order to send emails to groups or distribution lists.
Finally, it offers the flexibility to declare several SMTP configurations (via the graphical interface) which can then be used by command line mode and GUI mode.
The tool is natively in French but it is provided with an English translation. If you wish/can, you can contribute to the tool by translating it into other languages.
dipisoft.com/articles.php?lng=fr&pg=65&mnuid=2211&tconfig=0
The article is in French but you can translate it using the translation tool integrated into the site, in one of the blocks in the sidebar.
Regards,
damien.
the download link for sendsmtp does not work. is there another place to get it?
thanks
rich
The link has been updated, thanks for the report.
Which tool can send a signature line with logo
Any client that can send HTML messages with inline attachments.
Does any of above supports html formats?
CMail allows you to specify an HTML document to use as the message body.
Minirelay…
Mini-relay cannot be used to send mail from the command line. It only relays mail from other clients, much of which will end up in spam folders due to the sender not having their domain and server configured as per best practice.
Left off the list: NetMailBot (NetMailBot.com)
Great solution if you need to email automated responses from windows task scheduler where the option to email has been deprecated (i.e. functionality removed by microsoft). I selected SwithMail and it works perfectly with Win Server 2012 R2.
I decided I don’t care if the server backup is sucessful, I only want to know if it has failed so only need one custom task to send me an email when a backup fails.
example arguments…
/s /from adminemailaddress /pass yourpassword /server yoursmtprelayserver /p 25 /to recipientemail /sub “Server Backup Job Has Failed!” /b “Hi, the overnight Server Backup Job has Failed Please investigate and Ressolve as Rquired Server Admin”
Hope this helps.
SMTPS on port 465 has been considered deprecated since STARTTLS was introduced in 1998. CMail and mailsend support both methods, so the examples should be updated to be consistent with the other products.
E.g.
cmail.exe -starttls -host:[email protected]:[email protected]:587 -from:[email protected] -to:[email protected] -subject:subject -body:message
You may also wish to add notes about GMail authentication. Users may need to either enable the Less secure apps setting on your Google account, or configure an App Password if using 2-step verification in order to send mail via the service.
great article. Thanks.
by the way regarding the PowerShell Script to SendEmail any way to send it with an attached file?
Sorry, I got the right concept, but the wrong syntax for the way it’s used in the blog post. Try adding a line like this for the attachment:
$attachment = “c:\attachment.txt”
a very good tool is blat (www.blat.net)
I liked the CMail!!! It accepts attach files using wildcards (*.*, !*,*. etc).
Many thanks!
SmtpMail by SmtpInfo is perfect. smtpinfo.com
If you are logged in a Windows with an Active Directory user you can send authenticated emails without writting your user and password
But fully featured SmtpMail with authentication costs $49 while Mail Alert Simple Mailer (sourceforge.net/projects/mail-alert/) is free and supports safe authentication, BCC, CC, multiple recipients and any SMTP port while free SmtpMail edition don’t.
There is another cool commandline tool for sending emails:
sourceforge.net/projects/mail-alert/
It supports SSL and TLS, so you can configure your gmail address for sending emails.
thank you very much for the information, I created many programs in batch using some consoles, wget to download web pages or file. winrar console for actions on rar or zip files, fastman92imgconsole for working with files (.img). wbox, wfile, winput, wselect, and more did a program called (GTASA auto-installer creator) for the game gta san andreas and (GTASA audio-installer creator) with the help of the program autoplay menu designer did the menu.
and I had given up hope of making a program to send email, so we can send text messages to cell phones via email companies, and now thanks to this information I can continue my project, THANKS
7/26/15: things are a tad more difficult, I think, due to recent Security enhancements. I could not send anything via AT&T (kept getting Error Code 2 — later learned this is probably a password issue-could find out nothing except what the SMTP server URL might be).
I thought I also failed with Google, despite finding a HowTo. I eventually got a test email sent from Google to another account, immediately followed by a Google system-generated email that my account may have been hacked. There is an additional PIN security code that might be needed to remotely use the email account if it thinks it isn’t really me. I cannot find out how to program that because there is no info about it. There is an option to “lower the security settings on your account”. So, the thing that might work for me (I want to send myself an automatic email when a long programming build is finished) is to sign up for yet another Gmail account, lower its security settings, and use that instead of the real Google account. I want to use AutoIT (found a script for that!) to make a pre-written EXE emailer that I can include in a batchfile somewhere in the build.
nice info. thanks Ray
great.. i can use this for my visual basic project. thanks.
nice info raymond. thank you