Jun 10, 2019

A few words on email notifications in your workflow

I recently took time to set up my UPS notifications to myself through email. I couldn't stop just there and now my UPS, my system, my renders etc, they all send me notifications to my email. This is really neat thing to have.

You will need a way to access you transmitting email account through simple smtp (not all services offer simple smtp access) or you can (what I did) set up a local smtp server on your machine, there's a nice and free one called hMail Server (you'll need your own domain or dynamic dns service for it). The most powerful thing is that you can set up emails to be sent for literally everything happening with your system, cause there's a way to send custom messages right from windows PowerShell script.

It can be done in just one command line but I use this simple extended (more human readable) script:

$EmailTo = "mail@gmail.com"
$EmailFrom = "me@example.com"
$Subject = "topic"
$Body = "Hi"
$SMTPServer = "mail.example.com"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.EnableSsl = $false $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("me@example.com", "smtp password"); $SMTPClient.Send($SMTPMessage)

You save it as a simple text file, change the extension to .ps1 and use the command like

Call “E:\mydocs\sendemail.ps1”

to send the message to yourself. You can make plenty of them and add to windows Task Scheduler for each system event you want to be aware of.

If you interested I can make more extended tutorial for setting up your hMail server and configuring your domain’s DNS for it. Or you just DuckDuckGo for it, there’s already plenty of info online.

No comments:

Post a Comment