Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
Oh my god! I don't know how do I appreciate you. I'm trying this for months. After changing localhost to loopback address 127.0.0.1, the mail just went off. Thanks Richiv!. –  user53864 Sep 16 '10 at 0:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.