How to use gmail to send messages from command prompt?

February 10, 2014 at 13:07:54
Specs: WINDOWS SERVER 2008, 9.6GHZ/4GB
HAY PEOPLE,

I HAVE A QUESTION.
I DISCOVERED WERY USEFULL COMMAND IN COMMAND.COM
IT IS
POWERSHELL -COMMAND -SEND-MAILMESSAGE
I WANT TO WRITE A BATCH PROGRAM (WHICH CONTAINS MIXED CMD AND POWERSHELL CODE) WHICH WILL SEND ME AN E-MAIL MESSAGE WHENEVER SOMEONE STARTS WINDOWS ON MY COMPUTER.
BUT, I USE GMAIL ACCOUNT, AND IT LOOKS LIKE IT DOES NOT WORK WITH IT.
I TRIED THIS SCRIPT TO SEND A TEST MESSAGE AND IT DID NOT WORK:
INSIDE TEST.BAT:
@ECHO OFF
ECHO:SENDING TEST MAIL...
POWERSHELL -COMMAND SEND-MAILMESSAGE -TO "SYOBSYOT@GMAIL.COM" -FROM "SYOBSYOT@GMAIL.COM" -SUBJECT "TEST" -BODY "TESTING E-MAIL AUTOMATED SCRIPT" -SMTPSERVER "MAIL.GOOGLE.COM"
ECHO:FINISHED ATEMPTING TO SEND.
EXIT
BUT, THIS SCRIPT FAILS WITH THE FOLLOWING OUTPUT:
SENDING TEST MAIL...
Send-MailMessage : Unable to connect to the remote server
At line:1 char:17
+ SEND-MAILMESSAGE <<<< -TO "SYOBSYOT@GMAIL.COM" -from "SYOBSYOT@GMAIL.COM" -subject "TEST" -BODY "TESTING E-MAIL AUTOMATED SCRIPT" -SMTPSERVER "MAIL.GOOGLE.COM"
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
FINISHED ATEMPTING TO SEND.
I THINK THAT IT MIGHT BE BECAUSE GMAL REQUIRES USERNAME AND PASSWORD.
BUT, HOW TO SPECIFY IT IN THIS COMMAND?
AND, I THINK THAT IF THERE IS SOME ANONYMOUS SMTP SERVER THAT IT WOULD WORK WITHOUT USERNAME AND PASSWORD.

SO, DO YOU KNOW HOW TO FIX THIS, SO MY SCRIPTS CAN SEND E-MAILS FROM GMAIL FOR ME?
OR, IF IT CAN NOT BE DONE, WILL IT WORK WITH ANONYMOUS SMTP SERVER, AND IF IT WILL, HOW TO MODIFY THIS CODE TO USE IT WITH THAT SERVER?

ANY CODE MODIFICATIONS ARE WELCOME WITH THE ANSWER.

THANK YOU,
SYOB SYOT ♥
(BTW, I AM USING WINDOWS SERVER 2008 WITH POWERSHELL 2.0 AND CMD)


See More: How to use gmail to send messages from command prompt?

Report •

#1
February 27, 2014 at 18:26:19
Maybe a good idea would be to make it run gmail invisibly in the background, I made a program (out of laziness haha) to open my CD/DVD drive without me pushing the button, all I have to do is click the icon and I did this with batch using a code to run an individual feature of windows media player in the background. Works like a charm. So in summary, maybe try making it run Microsoft outlook, attached to your gmail, and send messages in the background, hope that helps! :)

Report •

#2
February 27, 2014 at 21:35:39
PROBABLY, BUT I AM NOT LOOKING FOR THAT.
I WANT TO USE POWER SHELL LANGUAGE FOR SENDING MESSAGES.
BUT, I ALREADY FOUND ANOTHER SOLUTION TO THIS. :)
THANX

Report •
Related Solutions


Ask Question