Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Hi currently Nagios sends notifications from, How do I go about configuring this? Thanks

share|improve this question

7 Answers 7

The above solutions did not work for me (running Nagios 4.0.8). What worked for me was adding " -r $ADMINEMAIL$" without the quotes before the -s (immediately after "/bin/mail"), and of course $ADMINEMAIL$ has to be set in nagios.cfg using the admin_email setting.

share|improve this answer
Hi Albert, and welcome to Server Fault and the Stack Exchange network. Unlike on a forum, answer order here is subject to change based on community voting and user preference, so referring to "above" and "below" is not guaranteed to remain consistent over time. I would encourage you to edit this answer to indicate which answers did not work, as that may provide useful information to future readers. – Michael Kjörling Mar 13 at 14:10

In a default Nagios install, it's also defined in the host-notify-by-mail or service-notify-by-mail commands, which you'll find in commands.cfg. The default would be something like:


So just add a -r sender@address option to the mail command, and that should work.

share|improve this answer
That's what I did, and it worked fine. Different alerts actually get sent out by different accounts because of our automated ticketing program. – breadly Oct 9 '09 at 17:25
I added this between /bin/mail and the -s – jgritty Nov 20 '14 at 0:50

None of the above works with current versions of Nagios and/or Postfix. The flag that needs to be added to the Nagios "host-notify-by-mail" or "service-notify-by-mail" commands in the file "commands.cfg" reads as follows:

-a "From:"

Note that the quotation marks are essential!

share|improve this answer

Both "-r" and "" worked for me.

The trick is to have these prefixed with " -- "

Thank you all for the tips.

share|improve this answer

I was able to do this by changing the command to something liek:

command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\Address: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$LONGSERVICEOUTPUT$" | /bin/mail -s "$SERVICESTATE$ - Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -- -r $ADMINEMAIL$

The magic is the '-- -r' part.

ADMINEMAIL is set in your nagios.cfg, but could be any email address for the 'From' address.

share|improve this answer

Couldn't get the "-- -r" solution to work. It turns out options after "--" are options for sendmail. Looking at sendmail options, it should be "-fnagios@domain" NOTE NO SPACE between -f and

So the following is now working :-

  command_line    /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\Address: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$LONGSERVICEOUTPUT$" | /bin/mail -s "$SERVICESTATE$ - Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ --
share|improve this answer

As documented at you can set admin_email to the value you want in the from field.

share|improve this answer
This is demonstrably wrong. – jgritty Nov 20 '14 at 0:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.