Nagios email notification to Office 365 not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mcortada
Posts: 9
Joined: Mon Jan 19, 2015 11:04 am

Nagios email notification to Office 365 not working

Post by mcortada »

Hello,

I just installed Nagios Core 4.2.2 in a new Ubuntu server 16.04 with Postfix.
Contact_group is added in each host and service with 24x7 and so on....


Postfix is configure to relay emails to Office 365. I am able to send a test email using below command, but I don't receive any notification email from Nagios.

$ echo "This is a test email from Ubuntu server" | mail -s "Relay Test Email" [email protected] -a "FROM:[email protected]"


Of course I have been reading but end up confused and lost.

Any help is more than Welcome please.

Thanks in advance

myt
Last edited by dwhitfield on Wed Nov 02, 2016 9:41 am, edited 1 time in total.
Reason: marking with green check mark
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios email notification to Office 365 not working

Post by dwhitfield »

Could you post your command definitions? Thanks!
mcortada
Posts: 9
Joined: Mon Jan 19, 2015 11:04 am

Re: Nagios email notification to Office 365 not working

Post by mcortada »

Command definitions are as follow (notify by email):

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios email notification to Office 365 not working

Post by rkennedy »

What is the output of which mail? The core commands as you can see are simply passing the printf data to /bin/mail. If which mail reports /bin/mail, then this should work fine.

Next step, is looking at how you specified the from address. Take a look at when your notification fires in Nagios, and look at /var/log/maillog - if you see something indicating it was rejected, or bounced, then the likely cause is it being blocked due to an invalid sender. You may want to append to your notify-host/service-by-email commands the -a parameter you were passing in your testing.

For example -

Code: Select all

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ -a "FROM:[email protected]"
}
This should send the same exact way your testing was.
Former Nagios Employee
mcortada
Posts: 9
Joined: Mon Jan 19, 2015 11:04 am

Re: Nagios email notification to Office 365 not working

Post by mcortada »

THANKSSSSS for your help


:D :D :D

It is working now, just changed to /usr/bin/mail and added the -a "FROM: "


I got the critical as well as the recovery notification!!!

Have a wonderful evening rkennedy!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios email notification to Office 365 not working

Post by dwhitfield »

Glad to hear it is resolved. Is it ok if we lock the thread? Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!
mcortada
Posts: 9
Joined: Mon Jan 19, 2015 11:04 am

Re: Nagios email notification to Office 365 not working

Post by mcortada »

Hi dwhitfield,

Yes, it is OK to lock the thread, please proceed.

Hoping this help other people.

Thanks a lot Nagios forums!

Loving Nagios :D
Locked