How to write a Windows batch script to send a mail? Give an example
相关问题
- xcopy include folder
- Batch file if string starts by
- Jenkins - cmd is not recognized
- String Manipulation with case sensitivity
- Writing an EXE output to a batch file
相关文章
- How do I make a forward e-mail link?
- Extracting columns from text file using Perl one-l
- Debug HTML Email in Gmail App
- Sending email using php, gmail, and swiftmailer ca
- How can one batch file get the exit code of anothe
- How to make jenkins fail at a failing windows batc
- Android - getting an error “no application can per
- Problems using start-process to call other powersh
I would suggest downloading and installing a command line emailing program. The best freeware one that I can see is:
http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm
From there, save the downloaded .exe to a good location on your HDD (possibly in c:/program files/bmail) and add that directory to your PATH ( see http://www.brightrev.com/how-to/windows/35-add-a-utilities-directory-to-your-pc.html?start=1 for instructions ).
From then, you could setup a small batch script such as this:
Then to send an email to that email address, just run the batch file.
If you want, you could change it to accept parameters so you can customise the message: http://www.robvanderwoude.com/parameters.php .
Important: I'm pretty sure bmail won't work if the SMTP server requires authentication, so you'll need to find one you can use. Maybe set one up on the server without a username and password, and that can only be accessed from localhost?
You will need to use a third party tool such as blat (http://www.blat.net/). Then in your batch file, you would have a line like the following:
blat -to foo@bar.com -f bar@foo.com -subject "Email Subject" -body "Email body" -server mysmtphost
You can enable the installed SMTP Server of Windows. And then run a power shell script: