-
Re: How to use a secondary smtp server.
msthursday Jul 13, 2009 5:53 PM (in response to msthursday)I made a couple of updates in order to get some alert details into the email:
External Process Configuration:
Failure Command Line: -command "& 'c:\scripts\mailserverdown.ps1' '%monitorname% %monitorstatus%' "
^----- update this to match the path and name of your script.
Updated Script: MailServerDown.ps1
#####################################
# Configure variables for email
#####################################
$filename = “”
$smtpServer = "mail-gw.company2.com"
$sender = ”ipmonitor@company1.com”
$recipient = "helpdesk@company2.com”
$subject = “company1 Mailserver Down”
#####################################
# Dump file into message body
#####################################
#$message = Get-Content $filename | out-string
$message = "This is an alert from the ipMonitor system at company1. `n"
$message = $message + "One of the mail servers has a down alert. Please investigate `n`n`n"
$message = $message + "Details = $args[0] `n"
#####################################
# Email Audit file to Admins
#####################################
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($sender, $recipient, $subject, $message)