Ubuntu – zabbix postfix gmail notification on ubuntu

Ubuntuzabbix

How to perfectly configure zabbix gmail notification with postfix(relay to gmail)
Actually this setup is working on my local machine but when I try to implement this on my real servers, email notification is failed and I could see the following error in Administration>audit>actions

Cannot connect to SMTP server [localhost] [gethost() failed for address 'localhost' [Success]]

my "/var/log/mail.log" message

Aug 26 00:14:31 station1 postfix/smtpd[9385]: connect from localhost.localdomain[127.0.0.1]
Aug 26 00:14:31 station1 postfix/smtpd[9385]: disconnect from localhost.localdomain[127.0.0.1]
Aug 26 00:15:31 station1 postfix/smtpd[9385]: connect from localhost.localdomain[127.0.0.1]
Aug 26 00:15:31 station1 postfix/smtpd[9385]: disconnect from localhost.localdomain[127.0.0.1]

I Checked my postfix gmail relay configuration with the telnet command as the folowing and connecting to smtp port 25

telnet localhost 25

And I could even send mail from terminal like

mail -s "Test mail" mymailid@gmail.com

The following are my media settings and this is the same settings which is working on my local machine

Type E-mail

SMTP server: localhost
SMTP helo: localhost
SMTP email: zabbix@localhost

Here are my settings.

/etc/hosts:

127.0.0.1 localhost.localdomain localhost
<my-ip-here> station1.lab.mycompany.com station1

/etc/zabbix/zabbix_agentd.conf:

# Default:
# Server=

Server=127.0.0.1

### Option: Hostname
# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server.
#
# Default:
# Hostname=system.uname

Hostname=Zabbix server

### Option: ListenPort
# Agent will listen on this port for connections from the server.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10050

/etc/zabbix/zabbix_agent.conf:

# This is a config file for zabbix_agent
# To get more information about Zabbix visit http://www.zabbix.com

### Option: Server
# IP address of Zabbix server
# Connections from other hosts will be denied
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: yes
# Default:
# Server=

Server=127.0.0.1

### Option: Timeout
# Spend no more than Timeout seconds on processing
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3

Hostname:

root@station1:~#hostname
station1.lab.mycompany.com 

The only difference between my real server and my local machine is the hostname.

I even tried changing my media settings to my server domain name and hostname but no use.

Please need help!.

Best Answer

try configuring e-mail server in zabbix media type configuration as 127.0.0.1, not localhost. if localhost resolves to ::1 and zabbix_server is compiled without ipv6 support, that may fail.

Related Topic