Question: Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.

May be if any batch which could be run to access our SMTP mail server.

Thanks in advance.

Answer: 
HowToGeek demonstrates a Windows PowerShell script that works very well at [How To Send Email From the Command Line in Windows Without Extra Software](http://www.howtogeek.com/120011/stupid-geek-tricks-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.
This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port

$securepass = ConvertTo-SecureString -String $yourpassword -A -F

$credential=new-object PSCredential $yourusername,$securepass

send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "subject" -body "message" -smtpserver smtp.gmail.com -port 587 -usessl -credential $credential -encoding utf8

Here is the script that can send mail from your Gmail:
<https://gallery.technet.microsoft.com/scriptcenter/PC-Utilities-Downloader-355e5bfe>