Page 1 of 1

Email notification won't send (Postfix)

Posted: Sat Apr 08, 2017 10:50 am
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=<[email protected]>
Apr  8 23:36:52 localhost postfix/qmgr[19718]: 822B86642A0: from=<[email protected]>, size=736, nrcpt=1 (queue active)
Apr  8 23:36:52 localhost postfix/error[20016]: 822B86642A0: to=<[email protected]>, 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.

Re: Email notification won't send (Postfix)

Posted: Mon Apr 10, 2017 11:12 am
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.

Re: Email notification won't send (Postfix)

Posted: Tue Apr 11, 2017 7:58 pm
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.

Re: Email notification won't send (Postfix)

Posted: Tue Apr 11, 2017 8:39 pm
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