You can use mailsend.exe to send emails from the command line or a script via a known SMTP server. More information and more ways to use this little useful utility here.
In the MS Exchange environment I used this method to send emails from batch jobs to internal email addresses. If you want to use this to send messages to external recipients you may need to configure Exchange relay options. Some additional info here.
An example of using mailsend.exe:
- Place mailsend1.16.exe in any folder
- In the same folder create send.bat file.
- Place the following command in send.bat (obviously changing domain, server IP address, and other details to match your environment)
mailsend1.16.exe -d your-domain-name -smtp 192.168.0.1 -t recipient@domain.com -f sender@domain.com -sub “Subject of your message” -M “message body text” - Run send.bat to send your email
- If you having any issues add switch -v to enable verbose mode
- If you want to add an attachment add -attach “image.jpg”,a where image.jpg file name of your attachment.
Tested on:
Exchange 2007
Windows Server 2003
Windows XP
Windows 7
Leave a Reply