Page 1 of 1

Help - how to use own email server?

Posted: Mon Jun 21, 2021 10:09 am
by jp.thiago
I have been using nagios for notification for a few years.

I use the default /usr/bin/mail, but my IP to be blocked by Spamhaus

I would like to continue using /usr/bin/mail, I would like to try using my email provider for this.

I changed the resource.cgf file including the lines below

$USER3$=xxx@xxx.com.br
$USER4$=xxxxxx (password)
$USER5$=smtp.xxxx.com.br:587

still using default account nagios@localhost.localdomain

I don't have much knowledge of linux (use centos os) I wanted to change it as simple as possible.

could they help?

Re: Help - how to use own email server?

Posted: Mon Jun 21, 2021 3:30 pm
by mcapra
Here's the manpage for mail:
https://linux.die.net/man/1/mail

Usually the hangup is with SMTP servers that have actual security features ...

There's a wide variety of CLI utilities you can use to interact in a secure fashion to send emails via a remote SMTP server:
* sendEmail (tutorial on integration with Nagios Core)
* sSMTP (Nagios Core tutorial)
* eMail

That list is far from exhaustive.

Re: Help - how to use own email server?

Posted: Tue Jun 22, 2021 7:24 am
by jp.thiago
sendmail configuration after installing sendmail package

$USER5$=email@gmail.com
$USER7$=smtp.gmail.com:587
$USER9$=email
$USER10$=password

---------------

is there any tutorial integrating mail and nagios? for a simple change like sendmail?

at this moment I changed the contact email @hotmail to @gmail

if you continue including on the blacklist I will test the integration with sendmail with nagios.

thank you so much!

Re: Help - how to use own email server?

Posted: Fri Jul 02, 2021 1:18 pm
by jp.thiago
What is the direct link from sendmail? the sendmail on the download site is customized.

I did the installations but shows SSL error using gmail.

the nagios code below is to be sent the email without ssl or tls authentication?

there is an error in the ssl.pm file on line 444

run run or lower test without problems

sendEmail -v -f $username -s $host -xu $username -xp $password -t $recipient -o tls=yes -u $subject -m $content

-------------------------------------------------------------------------

# '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/local/bin/sendEmail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
}

# '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$" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"