1 Reply Latest reply on Jul 13, 2009 5:53 PM by msthursday

    How to use a secondary smtp server.

      Hello,

      I recently setup ipMonitor to use an external process to send email to a backup smtp server in case of a mail server outage.  In case anyone else needs this info I'm documenting it below.

       

      Requirements:

      Install Powershell on your ipMonitor server.

       

      External Process Configuration:

      Executable Name:  powershell.exe

      Directory:  c:\windows\system32\windowspowershell\v1.0\

      Startup DIrectory: c:\scripts        <----  NOTE:  This is the directory where you save the script.

      Failure Command Line:  -command "& {c:\scripts\MailServerDown.ps1}"       <-----  update this to match the path and name of your script.

       

      Script:  MailServerDown.ps1

      #####################################
      #  Configure variables for email
      #####################################
      $filename = “”
      $smtpServer = "servername.company2.com"
      $sender = ”ipmonitor@company.com
      $recipient = "amanda@company2.com
      $subject = “Mailserver Down”

      #####################################
      #  Dump file into message body
      #####################################
      $message = "This is an alert from the ipMonitor system at Company.  One of the mail servers has a down alert.  Please investigate."
      #$message = Get-Content $filename | out-string    <---  You can use this to dump a file into your message body.  Just remove the '#' at the beginning

      #####################################
      #  Email Audit file to Admins
      #####################################
      $smtp = new-object Net.Mail.SmtpClient($smtpServer)
      $smtp.Send($sender, $recipient, $subject, $message)

      Last Step:

      Attach the external process to an alert.

       

      Kind Regards,

      Amanda

        • Re: How to use a secondary smtp server.

          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)