Will MailStore alert me when a job fails?
Of the many queries I see as a member of the MailStore support team here at Zen Software, this is one of the more common ones.
Unfortunately, for the time being at least, this isn’t something you can do from within the software but fear not – the reason for my post is that there is a workaround.
EDIT: Email reporting was introduced in v10.1 – more information here.
First, a couple of checks…
Before I start showing you the configuration steps, first we need to check the following is happening.
Check 1) It’s Windows 7/ 8/ 2008 or 2012 that we’re running
Check 2) MailStore is configured to store events in the Windows event log instead of the file system.
Check 3) The email account used to send the email alerts doesn’t containt a ‘$’ sign in it (well, you never know!).
Ok, with those out of the way we can move on to configuration.
Activating the auditing features
This method of alerting works by monitoring the MailStore audit events that are generated by the software and written to the Windows event log.
In order to generate these you must first enable the feature within MailStore:-
- Open the MailStore Client as administrator.
- Click on Administrative Tools > Compliance > Auditing.
- Activate the user activity ProfileRunArc.
UPDATE: On version 9 and above of MailStore you will also need to check that the Audit logs are being written to the Windows Event log not to a file log.
This can be set within the ‘Configure the MailStore Server Service” tool
Now, after archiving profiles have been executed, you’ll find the corresponding entries are being made in the event log.
How to check the Windows event logs manually
- Open the Event Viewer of your Windows system.
- Click on Event Viewer (local) > Windows Protocols > Applications.
- Search for events of source MailStore Server Auditing.
If errors occurred while executing the profile, the event level is Error. If the execution was successful, the level is Information.
In the next section we will monitor the log for any errors and trigger an email.
Setting up your notifications
In this example we’ll be using the Windows task scheduler to monitor for a specific event and then trigger a process off the back of it.
Let’s say you want to send an email when an ‘Archiving Failed’ event is written to the log. This is how you could go about doing it:
- Open the Task Scheduler of your Windows system
- Create a new folder, e.g. MailStore Auditing in the Task Scheduler Library
- Create a task via Actions > Create Task
- Please note that you will not Create a Simple Task
- Enter a meaningful name such as ‘MailStore Archiving Error’
- Select the option ‘Run whether user is logged on or not
- Under Configure for, select Windows Vista or Windows Server 2008 (otherwise the ‘Trigger On’ event is not available)
- Click on the ‘Triggers’ tab
- Click on ‘New’
- Under ‘Start Task’ select the value ‘On Event’
- Under ‘Settings’, activate the option ‘Custom’ and click on ‘New Event Filter’
- Under ‘Event Level’ place a check mark next to ‘Error’
- Select ‘Via Source’ and under ‘Sources’ place a check mark next to ‘MailStore Server Auditing’
- Click on ‘OK’ to save the settings
- Change to the ‘Actions’ tab
- Click on ‘New’
Use PowerShell to set up alert email
Before we can select the PowerShell script to run, we must first create it. Open Notepad and add the following content (be sure to adjust the values in red according to your mail environment):-
$EmailFrom = “firstname.lastname@example.org” $EmailTo = “email@example.com” $Subject = “MailStore Error” $Body = “Please check MailStore Server logs” $SMTPServer = “smtp.yourdomain.com” $SMTPPort = 25 $SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, $SMTPPort) $SMTPClient.EnableSsl = $false $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Once edited, save the script as c:\email-alert.ps1 (you may choose a different path for this). Now switch back to the task scheduler window:
- In the ‘Action’ field select ‘Start’ a program.
- As ‘Program/script’ enter ‘powershell.exe’
- As argument enter the path to the Powershell script e.g c:\email-alert.ps1
- Click ‘ok’ to save the Task.
Before we can run the script, the execution of scripts has to be enabled.
To do this so open Windows PowerShell and enter the command.
Lookout for those backup jobs
When I first set this up I was actually caught out straight away – immediately I was getting an error appearing every day at 7pm.
I could immediately rule out it being a random glitch and soon narrowed it down to being something outside of the control of MailStore. As it happened, eventually it twigged that it was our backup software interfering with the job each day.
Even though this backup was successful, the act of triggering the MailStore VSS writer must stop the current job running and therefore triggered the alert.
The simple fix was to exclude the time the backup job ran from the archive jobs ‘Automatic Mode’ so keep that in mind if you see the same error happen,
Let me know how you get on!
As always, I hope that’s something you can use – feel free to get in touch in the normal ways or leave a comment below if you’ve got a question.