I can’t find anywhere in the Windows Server 2012 (R2) settings to allow an email notification when a server backup completes successfully. Windows Server 2012 Essentials has a nice feature that you allows you to get email reports on your backup status. This helps keep tabs on your server without logging in everytime. I wanted a similar notification for when a Windows Server 2012 backed up successfully.
After some research online this is how I found to accomplish this task.
Part One of Tutorial
Lets create a Powershell script. This script will allow us to send email.
Use this Powershell script. Please note your username and password isn’t encrypted. There are ways to encrypt your password but the following tutorial doesn’t show you how to.
$EmailFrom = “email@example.com”
$EmailTo = “firstname.lastname@example.org”
$Subject = “Notification from XYZ”
$Body = “this is a notification from XYZ Notifications..”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Just change $EmailTo, and username/password in $SMTPClient. For the credentials don’t include @gmail.com in your username.
Thanks to Christian Muggli for this script.
Log into your Gmail account and make sure two factor authentication is turned off. Also make sure less secure apps are enabled. Visit this site https://www.google.com/settings/security/lesssecureapps to find out if it is enabled or not. If it isn’t enabled you will get this error message.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 authentication required. Continue reading