Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I spent last 3 hours of reasearch on how to get nagios to work with email notifications, i need to send emails form work where the only accesible smtp server is the company's one.

i managed to get it done from the console using:

mail adam.xxxx@gmail.com

working perfectly for the purpouse i set up ssmtp.conf so as:

root=adam.xxxx@company.pl
mailhub=smtp.company.com:587
AuthUser=adam.xxx@company.pl
AuthPass=mypassword
FromLineOverride=YES
useSTARTTLS=YES
rewriteDomain=company.pl
hostname=nagios
UseTLS=YES

i also edited the file /etc/ssmtp/revaliases so as:

root:adam.xxxx@company.com:smtp.company.com:587
nagios:adam.xxxx@company.com:smtp.company.com:587
nagiosadmin:adam.xxxx@company.com:smtp.company.com:587

i also edited the file permisions for /etc/ssmtp/* so as:

-rwxrwxrwx 1 root nagios  371 lis 22 15:27 /etc/ssmtp/revaliases
-rwxrwxrwx 1 root nagios 1569 lis 22 17:36 /etc/ssmtp/ssmtp.conf

and i assigned to proper groups i belive:

cat /etc/group |grep nagios
mail:x:12:mail,postfix,nagios
mailnull:x:47:nagios
nagios:x:2106:nagios
nagcmd:x:2107:nagios

when i send mail manualy, i recieve it on my priv box, but when i send mail from nagios the mail log says:

Nov 22 17:47:03 certa-vm2 sSMTP[9099]: MAIL FROM:<root@company.pl> 
Nov 22 17:47:03 certa-vm2 sSMTP[9099]: 550 You are not allowed to send mail from this address

it says root@company.com and im not allowed to send mails claiming to be root@company.com, its suppoused to be adam.xxxx@company.com, what am i doing wrong? i ran out of tricks...

kind regards Adam xxxx

share|improve this question
add comment

1 Answer

You need to modify the nagios notification commands to pass in whatever CLI arguments mail/ssmtp is expecting to set the "from" address.

The specifics of how to do this vary by MTA, but I believe ssmtp implements a sendmail-compatible interface, so you should be able to just tack this on the end of your notification commands:

-- -f adam.xxxx@company.com

Double-check the manpage for 'mail' to confirm that '--' lets you pass sendmail options through to the MTA, and then check the manpage for 'sendmail' to confirm that '-f' will set the "from" address.

share|improve this answer
    
I belive it was a PEBKAC, i didnt reboot the virtual machine after changing nagios group and it somehow started to work on its own. the -- -f option, revalaiases should replace it properly. –  adam Nov 26 '12 at 7:31
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.