Sending Notifications as a Different User


Currently I am porting an old Nagios setup on a discontinued domain to a new domain. My Nagios is configured as well as sendmail to e-mail the IT department about down services. However in order for the e-mails to be received, Nagios needs to send the notifications from a valid user and NOT nagios at localhost.localdomain otherwise the e-mails get dropped. I do not have control over the SMTP relay or e-mail servers so I can not just allow these e-mails to come through.

I have looked all over for a way to configure this but I can’t seem to get it working. My notifications work if I point them to a different SMTP relay, so I know that my sendmail configuration is correct. I understand that this may also be a sendmail issue and not something that can be controlled by Nagios, but I figured if Nagios is sending the notifications maybe there is a way to send those notifications as someone specifically. I will post any configs that you think will help solve the issue. I am running Centos 5 with Nagios 2.12.



I’m not sure, but if you’re using sendmail, have you tried the “-f” option: (from man sendmail)
-f name Sets the name of the “from” person (that is, the sender of the mail).

I’m not really good at SMTP problems, but it might work :slight_smile:
(or any other vicious way to fake your ID could be ok)


Testing from the command line using sendmail -f I am able to send mail. This at least confirms that sendmail will be able to send out the notifications to the addresses in contacts.cfg as long as Nagios sends them as a valid address.

However, this still does not solve the problem of the notifications coming from nagios at localhost.localdomain.


One way is to edit your sendmail config and fix the masquerade options…

[root@localhost ~]# cat /etc/mail/ divert(-1)dnl dnl # dnl # This is the sendmail macro config file for m4. If you make changes to dnl # /etc/mail/, you will need to regenerate the dnl # /etc/mail/ file by confirming that the sendmail-cf package is dnl # installed and then performing a dnl # dnl # make -C /etc/mail dnl # ... LOCAL_DOMAIN(`localhost.localdomain')dnl dnl # dnl # The following example makes mail from this host and any additional dnl # specified domains appear to be sent from dnl # MASQUERADE_AS(`')dnl dnl # dnl # masquerade not just the headers, but the envelope as well dnl # FEATURE(masquerade_envelope)dnl dnl # dnl # masquerade not just, but @* as well dnl # FEATURE(masquerade_entire_domain)dnl dnl # MASQUERADE_DOMAIN(localhost)dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl dnl MASQUERADE_DOMAIN( ...
Then do the make -C command as indicated and restart sendmail




Thanks Strides!
It might be useful :wink:


Success! That is exactly what it needed because now the notifications are sent from nagios at Thank you for making sense of the MASQUERADE options. I had a feeling that is what was needed but I didn’t understand which options I needed and which weren’t.