1

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

adam
  • 11
  • 2

1 Answers1

0

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.

Keith
  • 4,637
  • 15
  • 25
  • 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 07:31