Can't get email notifications with SSMTP
Posted: Tue Jun 19, 2018 4:27 pm
Hello,
I configured SSMTP to send emails, from the terminal I'm not having problems but sending email alerts for Nagios is not working.
I attach you the 2 commands that I have for send emails on commands.cfg
# '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" | /usr/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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
This what I have from \var/log/mail.log
Jun 19 23:14:52 sdnagios01 sSMTP[2117]: Creating SSL connection to host
Jun 19 23:14:52 sdnagios01 sSMTP[2117]: SSL connection using RSA_AES_128_CBC_SHA1
Jun 19 23:14:55 sdnagios01 sSMTP[2117]: Sent mail for root@sdnagios01 (221 2.0.0 closing connection k36-v6sm1278389wrc.20 - gsmtp) uid=0 username=root outbytes=541
Jun 19 23:15:15 sdnagios01 sSMTP[2129]: Creating SSL connection to host
Jun 19 23:15:15 sdnagios01 sSMTP[2129]: SSL connection using RSA_AES_128_CBC_SHA1
Jun 19 23:15:17 sdnagios01 sSMTP[2129]: Sent mail for root@sdnagios01 (221 2.0.0 closing connection n7-v6sm711134wrr.39 - gsmtp) uid=0 username=root outbytes=541
On contacts.cfg I have the following
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
I don't know whatelse to check, any idea?
Thanks in advance for helping me
Best regards
I configured SSMTP to send emails, from the terminal I'm not having problems but sending email alerts for Nagios is not working.
I attach you the 2 commands that I have for send emails on commands.cfg
# '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" | /usr/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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
This what I have from \var/log/mail.log
Jun 19 23:14:52 sdnagios01 sSMTP[2117]: Creating SSL connection to host
Jun 19 23:14:52 sdnagios01 sSMTP[2117]: SSL connection using RSA_AES_128_CBC_SHA1
Jun 19 23:14:55 sdnagios01 sSMTP[2117]: Sent mail for root@sdnagios01 (221 2.0.0 closing connection k36-v6sm1278389wrc.20 - gsmtp) uid=0 username=root outbytes=541
Jun 19 23:15:15 sdnagios01 sSMTP[2129]: Creating SSL connection to host
Jun 19 23:15:15 sdnagios01 sSMTP[2129]: SSL connection using RSA_AES_128_CBC_SHA1
Jun 19 23:15:17 sdnagios01 sSMTP[2129]: Sent mail for root@sdnagios01 (221 2.0.0 closing connection n7-v6sm711134wrr.39 - gsmtp) uid=0 username=root outbytes=541
On contacts.cfg I have the following
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
I don't know whatelse to check, any idea?
Thanks in advance for helping me
Best regards