Send Email via Gmail from Command Prompt

6

2

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?

Matt Hanson

Posted 2009-12-08T06:47:10.393

Reputation: 922

Answers

8

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

Some command-line mail products for Windows are:

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

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

harrymc

Posted 2009-12-08T06:47:10.393

Reputation: 306 093

If it's from a "remote server" you need to enable some security measures too, see the various answers here: https://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail/49429541#49429541

– rogerdpack – 2018-03-22T13:10:30.667

2

Blat:

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

Anonymous Cowardice

Posted 2009-12-08T06:47:10.393

Reputation: 21

2

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 = “yourMail@gmail.com”
$EmailTo = “theRecipient'sAddress@someServer.com”
$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.

Oz Edri

Posted 2009-12-08T06:47:10.393

Reputation: 259

0

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/

Pratik Singhal

Posted 2009-12-08T06:47:10.393

Reputation: 187