I've got some backup jobs running weekly and would like to have the log files sent to me automatically via email so I don't have to manually check them.

On a Windows system, is there a tool that I can use that will allow me to send an email via Gmail SMTP from a command prompt?

5 Answers 5


Gmail can be used for sending mail by any mail program and from any network.

Some command-line mail products for Windows are:

(I have no first-hand experience with these products.)

See also this article : How to use Gmail as your SMTP server.



What is Blat?
Blat is a Win32 command line utility that sends eMail using SMTP or post to usenet using NNTP.


HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software

Here is the method: First you're defining the variables:

$EmailFrom = “[email protected]
$EmailTo = “theRecipient'[email protected]
$Subject = “your subject”
$Body = “some text”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);

Then, you're using this command to send the mail:

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

You'll need a valid Gmail account in order to authenticate as a Gmail user.


Currently in powershell we can use Send-MailMessage cmdlet without using .NET:

$Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);
Send-MailMessage -From 'enterYourEmailHere ' -To 'enterRecipientMailHere' -Subject 'Email subject' -Body 'EnterBodyHere as HTML'  -Attachment 'Attachment path here' -SmtpServer 'smtp.gmail.com' -Port 587 -UseSSL -BodyAsHTML -Credential $Credentials 

Send-MailMessage Documentation


You can use the following java program to send email through command line https://ps06756.wordpress.com/2017/08/17/how-to-send-email-through-gmail-programmatically/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .