Email notification won't send (Postfix)

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
hr7
Posts: 2
Joined: Sat Apr 08, 2017 10:34 am

Email notification won't send (Postfix)

Post by hr7 »

HI, I've been trying to send an email notification to gmail or even other email address but it won't send. The web interface has shown that it has send the email. I take a look at the postfix mail log and below are the error. I'm using CentOs 7 and Nagios 4.3.1

Code: Select all

Apr  8 23:36:52 localhost postfix/pickup[19717]: 822B86642A0: uid=1001 from=<nagios>
Apr  8 23:36:52 localhost postfix/cleanup[20014]: 822B86642A0: message-id=<20170408153652.822B86642A0@localhost.localdomain>
Apr  8 23:36:52 localhost postfix/qmgr[19718]: 822B86642A0: from=<nagios@localdomain.localdomain>, size=736, nrcpt=1 (queue active)
Apr  8 23:36:52 localhost postfix/error[20016]: 822B86642A0: to=<example@gmail.com>, relay=none, delay=0.06, delays=0.04/0.01/0/0.01, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to alt2.gmail-smtp-in.l.google.com[74.125.30.26]:25: Connection timed out)
and here are the postfix configuration.

Code: Select all

myhostname = localhost.localdomain
mydomain = localdomain
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost, $mydomain
mynetworks = 127.0.0.0/8, 192.168.1.0/24
relay_domains = $mydestination
my mail path and command.cfg lines.

Code: Select all

/usr/bin/mail

# '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$
	}
Please point out my mistake. I've been trying to send an email for 3 days. Your help is highly appreciated.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Email notification won't send (Postfix)

Post by avandemore »

This is the issue:

Code: Select all

(delivery temporarily suspended: connect to alt2.gmail-smtp-in.l.google.com[74.125.30.26]:25: Connection timed out)
From my terminal:

Code: Select all

# telnet 74.125.30.26 25
Trying 74.125.30.26...
Connected to 74.125.30.26.
Escape character is '^]'.
220 mx.google.com ESMTP g10si1087889otc.146 - gsmtp
So there is some type of networking issue afoot.
Previous Nagios employee
hr7
Posts: 2
Joined: Sat Apr 08, 2017 10:34 am

Re: Email notification won't send (Postfix)

Post by hr7 »

avandemore wrote:This is the issue:

Code: Select all

(delivery temporarily suspended: connect to alt2.gmail-smtp-in.l.google.com[74.125.30.26]:25: Connection timed out)
From my terminal:

Code: Select all

# telnet 74.125.30.26 25
Trying 74.125.30.26...
Connected to 74.125.30.26.
Escape character is '^]'.
220 mx.google.com ESMTP g10si1087889otc.146 - gsmtp
So there is some type of networking issue afoot.
Is it because of the firewall? how do I fix it? I already put my network on main.cf file but it's not working.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Email notification won't send (Postfix)

Post by dwhitfield »

This is not really a Nagios question, but if you post the output of traceroute 74.125.30.26, it may be obvious. You may have to install traceroute first. yum install traceroute in your case
Locked