I have some windows vps servers and when they are restarted I want to receive an email when they do, just so that I know what’s going on.
After some searching I found a great, free little utility called mailsend.exe
mailsend is not fancy and can only be run through the command line, but what it does allow is configuration of smtp servers, so in the case your vps has port 25 blocked, then just use gmail as your external mail server.
Here is an example of how an email can be sent from the command line using mailsend:
mailsend.exe -t firstname.lastname@example.org -f email@example.com -ssl -port 465 -auth -smtp smtp.gmail.com -sub subject -M message -user firstname.lastname@example.org -pass YourGmailPassword
Of course if you wanted to make this automated when the server starts up, just follow the directions below.
1. Download mailsend from mailsend
2. Install mailsend.exe into your C:\ drive (or anywhere you want)
3. Open the command line (Start > cmd)
4. Create a batch file in the startup folder of your machine by pasting the command below into your terminal window (of course, replace your details first).
set command=C:\mailsend.exe -t email@example.com -f firstname.lastname@example.org -ssl -port 465 -auth -smtp smtp.gmail.com -sub "server 1 restarted" -M "server 1 was restarted" -user email@example.com -pass YourGmailPassword exit
echo %command% > "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\email_on_restart.bat"
If you then check in your startup folder you will see a new bat file in there so when the windows vps is restated it will pump an email out to you letting you know that the machine just restarted.