Emailing with batch
Moderator: DosItHelp
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Emailing with batch
ok, so on my flash drive I have a security system. (at my school the computers don't show hidden files) and the only one not hidden is the in that makes you put in a pass word. if it is wrong, it alerts the user with text and a voice. it also snaps a screenshot and prints all the info in a security log. my question is how to get it to e-Mail me. I wish to do this with att (see below), and it will have to work completely off my flash drive, no port forwards or anything (it will be at school) I am fine with using third party tools as long as it is, like 1 o 2 files and they work! am using at&t for my email, this will let me text my phone!
(as you can tell I am security oriented guy and it would be so cool to make this work)
Requrements:
has to run completely off a flashdrive
has to be fast (before someone could say, close the window)
has to be invisible, like echo hello >nul invisible
I have looked EVERYWHERE and can not find some that meets all this. I hope y'all can help me
thanks
-notelek labs
(as you can tell I am security oriented guy and it would be so cool to make this work)
Requrements:
has to run completely off a flashdrive
has to be fast (before someone could say, close the window)
has to be invisible, like echo hello >nul invisible
I have looked EVERYWHERE and can not find some that meets all this. I hope y'all can help me
thanks
-notelek labs
Re: Emailing with batch
Notelek_Labs wrote:has to be fast (before someone could say, close the window)
When sending an email the program has to log into the server and you are at the mercy of the server as to how long it takes to log in - and then send the email.
So I guess whatever program you use could fail that requirement.
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Re: Emailing with batch
by fast i mean like 20-30 seconds if its longer maybe i can shave some time off something else
Re: Emailing with batch
Try this:
Code: Select all
::email-bat.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
:: defaults
set From=me@here.com.au
set To=you@lavabit.com
set Subj="email test %date% %time%"
set Body="did it work? %date% %time%"
set Serv=mail.server.com.au
set Auth=user
set Pass=pass
set fileattach=
:: if command line arguments are supplied then use them
if "%~7" NEQ "" (
set From=%1
set To=%2
set Subj="%~3"
set Body="%~4"
set Serv=%5
set "Auth=%~6"
set "Pass=%~7"
set "fileattach=%~8"
)
call :createVBS "email-bat.vbs"
call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
del "%vbsfile%" 2>nul
goto :EOF
:send
cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 >nul 2>nul
goto :EOF
:createVBS
set "vbsfile=%~1"
del "%vbsfile%" 2>nul
set cdoSchema=http://schemas.microsoft.com/cdo/configuration
echo >>"%vbsfile%" Set objArgs = WScript.Arguments
echo >>"%vbsfile%" Set objEmail = CreateObject("CDO.Message")
echo >>"%vbsfile%" objEmail.From = objArgs(0)
echo >>"%vbsfile%" objEmail.To = objArgs(1)
echo >>"%vbsfile%" objEmail.Subject = objArgs(2)
echo >>"%vbsfile%" objEmail.Textbody = objArgs(3)
if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%"
echo >>"%vbsfile%" with objEmail.Configuration.Fields
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusing") = 2 ' not local, smtp
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserver") = objArgs(4)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserverport") = 25
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusername") = objArgs(5)
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendpassword") = objArgs(6)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = False
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpconnectiontimeout") = 25
echo >>"%vbsfile%" .Update
echo >>"%vbsfile%" end with
echo >>"%vbsfile%" objEmail.Send
rem
Last edited by foxidrive on 23 Jul 2012 10:20, edited 1 time in total.
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Re: Emailing with batch
nope, it doesn't error, but I don't have an email from it either. Check my Code:
Code: Select all
@echo off
setlocal
:: defaults
set From=me@here.com.au
set To=mfoulks1@gmail.com
set Subj="email test %date% %time%"
set Body="did it work? %date% %time%"
set Serv=smtp.gmail.com
set Auth=mfoulks1
set Pass=YEA YOU WISH(Not my real pass)
set fileattach=
:: if command line arguments are supplied then use them
if "%~7" NEQ "" (
set From=%1
set To=%2
set Subj="%~3"
set Body="%~4"
set Serv=%5
set "Auth=%~6"
set "Pass=%~7"
set "fileattach=%~8"
)
call :createVBS "email-bat.vbs"
call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
del "%vbsfile%" 2>nul
goto :EOF
:send
cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 >nul 2>nul
goto :EOF
:createVBS
set "vbsfile=%~1"
del "%vbsfile%" 2>nul
set cdoSchema=http://schemas.microsoft.com/cdo/configuration
echo >>"%vbsfile%" Set objArgs = WScript.Arguments
echo >>"%vbsfile%" Set objEmail = CreateObject("CDO.Message")
echo >>"%vbsfile%" objEmail.From = objArgs(0)
echo >>"%vbsfile%" objEmail.To = objArgs(1)
echo >>"%vbsfile%" objEmail.Subject = objArgs(2)
echo >>"%vbsfile%" objEmail.Textbody = objArgs(3)
if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%"
echo >>"%vbsfile%" with objEmail.Configuration.Fields
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusing") = 2 ' not local, smtp
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserver") = objArgs(4)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserverport") = 25
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusername") = objArgs(5)
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendpassword") = objArgs(6)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = False
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpconnectiontimeout") = 25
echo >>"%vbsfile%" .Update
echo >>"%vbsfile%" end with
echo >>"%vbsfile%" objEmail.Send
Re: Emailing with batch
Notelek_Labs wrote:nope, it doesn't error, but I don't have an email from it either. Check my Code:
You can't send from gmail using a non registered email name. You have to use your email address.
Also, add this as the very last line: see my edit above.
rem
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Re: Emailing with batch
changed it, but It is Still no working
Code:
Code:
Code: Select all
@echo off
setlocal
:: defaults
set From=noteleklabssecuredevices@gmail.com
set To=Nope, not postin it@txt.att.net
set Subj="email test %date% %time%"
set Body="did it work? %date% %time%"
set Serv=gmail.com
set Auth=noteleklabssecuredevices
set Pass=Not Stupid
set fileattach=
:: if command line arguments are supplied then use them
if "%~7" NEQ "" (
set From=%1
set To=%2
set Subj="%~3"
set Body="%~4"
set Serv=%5
set "Auth=%~6"
set "Pass=%~7"
set "fileattach=%~8"
)
call :createVBS "email-bat.vbs"
call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
del "%vbsfile%" 2>nul
goto :EOF
:send
cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 >nul 2>nul
goto :EOF
:createVBS
set "vbsfile=%~1"
del "%vbsfile%" 2>nul
set cdoSchema=http://schemas.microsoft.com/cdo/configuration
echo >>"%vbsfile%" Set objArgs = WScript.Arguments
echo >>"%vbsfile%" Set objEmail = CreateObject("CDO.Message")
echo >>"%vbsfile%" objEmail.From = objArgs(0)
echo >>"%vbsfile%" objEmail.To = objArgs(1)
echo >>"%vbsfile%" objEmail.Subject = objArgs(2)
echo >>"%vbsfile%" objEmail.Textbody = objArgs(3)
if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%"
echo >>"%vbsfile%" with objEmail.Configuration.Fields
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusing") = 2 ' not local, smtp
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserver") = objArgs(4)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserverport") = 25
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusername") = objArgs(5)
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendpassword") = objArgs(6)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = False
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpconnectiontimeout") = 25
echo >>"%vbsfile%" .Update
echo >>"%vbsfile%" end with
echo >>"%vbsfile%" objEmail.Send
rem
Re: Emailing with batch
I believe for gmail your username (auth) needs to be your full email address. Also not sure if you some how you need to specify the PORT for the SMTP server.
If your client does not support SMTP4 authentication, you won't be able to send mail through your client using your Gmail address.
If you're having trouble sending mail but you've confirmed that encryption is active for SMTP in your mail client, try to configure your SMTP server on a different port (465 or 587).
Re: Emailing with batch
If you change the SMTPserverport and SSL settings, it should work with Gmail.
http://cybernetnews.com/vbscript-send-e ... ing-gmail/
http://cybernetnews.com/vbscript-send-e ... ing-gmail/
Re: Emailing with batch
@Squashman, you make a good point. Gmail does indeed require (a) the full address for authentication, (b) secure smtp, for example SSL on port 465, and last but not least (c) the account itself to be enabled for POP/SMTP.
@Notelek_Labs, your code has the protocol set to unsecure port 25, which I don't think gmail likes. See the required settings at http://support.google.com/mail/bin/answ ... swer=13287. The other thing you don't mention is how you call the batch file - I'd assume you pass the arguments on the command line, in which case make sure they are quoted as necessary.
Liviu
@Notelek_Labs, your code has the protocol set to unsecure port 25, which I don't think gmail likes. See the required settings at http://support.google.com/mail/bin/answ ... swer=13287. The other thing you don't mention is how you call the batch file - I'd assume you pass the arguments on the command line, in which case make sure they are quoted as necessary.
Liviu
Re: Emailing with batch
Greetings Notelek_Labs,
I do not use Gmail but the script works for me on my ISP.
Try placing a 'PAUSE' in the script to see if that helps
ferret out the error.
For example:
Good luck!
I do not use Gmail but the script works for me on my ISP.
Try placing a 'PAUSE' in the script to see if that helps
ferret out the error.
For example:
Code: Select all
call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
PAUSE
del "%vbsfile%" 2>nul
goto :EOF
Good luck!
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Re: Emailing with batch
Current code:
Code: Select all
@echo off
setlocal
:: defaults
set From=noteleklabssecuredevices@gmail.com
set To=ASLO CENCORED@txt.att.net
set Subj="email test %date% %time%"
set Body="did it work? %date% %time%"
set Serv=smtp.gmail.com:465
set Auth=noteleklabssecuredevices@gmail.com
set Pass=CENCORED
set fileattach=
:: if command line arguments are supplied then use them
if "%~7" NEQ "" (
set From=%1
set To=%2
set Subj="%~3"
set Body="%~4"
set Serv=%5
set "Auth=%~6"
set "Pass=%~7"
set "fileattach=%~8"
)
call :createVBS "email-bat.vbs"
call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
del "%vbsfile%" 2>nul
goto :EOF
:send
cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 >nul 2>nul
goto :EOF
:createVBS
set "vbsfile=%~1"
del "%vbsfile%" 2>nul
set cdoSchema=http://schemas.microsoft.com/cdo/configuration
echo >>"%vbsfile%" Set objArgs = WScript.Arguments
echo >>"%vbsfile%" Set objEmail = CreateObject("CDO.Message")
echo >>"%vbsfile%" objEmail.From = objArgs(0)
echo >>"%vbsfile%" objEmail.To = objArgs(1)
echo >>"%vbsfile%" objEmail.Subject = objArgs(2)
echo >>"%vbsfile%" objEmail.Textbody = objArgs(3)
if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%"
echo >>"%vbsfile%" with objEmail.Configuration.Fields
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusing") = 2 ' not local, smtp
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserver") = objArgs(4)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserverport") = 25
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusername") = objArgs(5)
echo >>"%vbsfile%" .Item ("%cdoSchema%/sendpassword") = objArgs(6)
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = False
echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpconnectiontimeout") = 25
echo >>"%vbsfile%" .Update
echo >>"%vbsfile%" end with
echo >>"%vbsfile%" objEmail.Send
rem
Re: Emailing with batch
No! Look at the Link I gave you and look at the Code Foxi gave you. You should see where to set the Server Port and SSL settings! Reading is FUN!
-
- Posts: 16
- Joined: 22 Jul 2012 20:26
Re: Emailing with batch
Ok first off, read my first post. I have scoured google and saw squa's link already and understand simple mail transfer protocol. I just don't get what you are asking about ssl squa.
Re: Emailing with batch
Notelek_Labs wrote:Ok first off, read my first post. I have scoured google and saw squa's link already and understand simple mail transfer protocol. I just don't get what you are asking about ssl squa.
You realize what the spelling of squa means?