Solved Postfix email problem with Gmail

Hello everyone,

I just installed postfix and when running sendmail -bv root I get the following:
Code:
Mar  7 21:02:08 FREEBSD_HOST sendmail[1940]: gethostbyaddr(192.168.0.115) failed: 1
Mar  7 21:02:08 FREEBSD_HOST sendmail[1940]: gethostbyaddr(192.168.0.120) failed: 1
Mar  7 21:02:08 FREEBSD_HOST sendmail[1940]: gethostbyaddr(192.168.0.125) failed: 1
I have disabled everything in relation to sendmail, so I really dont get the error message.

For your information 192.168.0.115, 192.168.0.120 and 192.168.0.125 are the IP address of my three jails. I read on the net that it could be because I didn't add the following in my /etc/make.conf file to disable building Sendmail during buildworld.
Code:
NO_SENDMAIL=true
If this is the case does anyone know how to fix it?

/etc/rc.conf
Code:
postfix_enable="YES"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
/etc/periodic.conf
Code:
daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"
etc/postfix/main.cf
Code:
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/usr/local/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_use_tls = yes
/etc/postfix/sasl_passwd
Code:
[smtp.gmail.com]:587 myemail@gmail.com:password

Thank you in advance.
 
Re: Postfix email problem with Gmail

What do you have in /etc/mail/mailer.conf? As a reference, this is what I have, when no Sendmail alternative has been installed
Code:
# cat /etc/mail/mailer.conf
# $FreeBSD: release/9.1.0/etc/mail/mailer.conf 93858 2002-04-05 04:25:14Z gshapiro $
#
# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
#
sendmail        /usr/libexec/sendmail/sendmail
send-mail       /usr/libexec/sendmail/sendmail
mailq           /usr/libexec/sendmail/sendmail
newaliases      /usr/libexec/sendmail/sendmail
hoststat        /usr/libexec/sendmail/sendmail
purgestat       /usr/libexec/sendmail/sendmail

See mailer.conf(5).
 
Re: postfix email problem with gmail

NO_SENDMAIL is long obsolete. The modern equivalent is setting
Code:
WITHOUT_SENDMAIL
in /etc/src.conf.

Neither of these deletes binaries that are already present.
 
Re: Postfix email problem with Gmail

Hi @J65nko,

cat /etc/mail/mailer.conf
Code:
# $FreeBSD: release/10.0.0/etc/mail/mailer.conf 93858 2002-04-05 04:25:14Z gshapiro $
#
# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
#
sendmail        /usr/libexec/sendmail/sendmail
send-mail       /usr/libexec/sendmail/sendmail
mailq           /usr/libexec/sendmail/sendmail
newaliases      /usr/libexec/sendmail/sendmail
hoststat        /usr/libexec/sendmail/sendmail
purgestat       /usr/libexec/sendmail/sendmail

I have exactly the same content as you have. Have you got any other suggestions please?
 
Last edited by a moderator:
Re: Postfix email problem with Gmail

wblock@ said:
NO_SENDMAIL is long obsolete. The modern equivalent is setting
Code:
WITHOUT_SENDMAIL
in /etc/src.conf.

Neither of these deletes binaries that are already present.

Hi, is the code that I need in /etc/src.conf
Code:
WITHOUT_SENDMAIL
or
Code:
WITHOUT_SENDMAIL="NO"
Do I need to remove the current setting from my rc.conf file?
 
Re: Postfix email problem with Gmail

fred974 said:
Hi @J65nko,

cat /etc/mail/mailer.conf
Code:
# $FreeBSD: release/10.0.0/etc/mail/mailer.conf 93858 2002-04-05 04:25:14Z gshapiro $
#
# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
#
sendmail        /usr/libexec/sendmail/sendmail
send-mail       /usr/libexec/sendmail/sendmail
mailq           /usr/libexec/sendmail/sendmail
newaliases      /usr/libexec/sendmail/sendmail
hoststat        /usr/libexec/sendmail/sendmail
purgestat       /usr/libexec/sendmail/sendmail

I have exactly the same content as you have. Have you got any other suggestions please?
Only a repeated hint to read mailer.conf(5) ;) That man page states:
Code:
This example shows	how to invoke a	sendmail-workalike like	Postfix	in
     place of sendmail(8):

	   # Emulate sendmail using postfix
	   sendmail	   /usr/local/sbin/sendmail
	   send-mail	   /usr/local/sbin/sendmail
	   mailq	   /usr/local/sbin/sendmail
	   newaliases	   /usr/local/sbin/sendmail[/quote]

When you installed Postfix through FreeBSD ports or packages, your current "Sendmail" version of /etc/mail/mailer.conf should have been replaced with one that invokes postfix.

When your updated or rebuilt your system from source, probably the "Postfix" version of this file was replaced by a standard "Sendmail" one.
 
Last edited by a moderator:
Re: Postfix email problem with Gmail

Looking at your logfiles, I see your server is behind NAT. If it is, then add this to main.cf:
Code:
proxy_interfaces = 11.22.33.44
Where 11.22.33.44 is your external IP address. I run a Postfix mail server behind a Linksys E900 running Tomato with 1:1 NAT and have no problems at all with this setup.
 
Re: Postfix email problem with Gmail

Updated my mailer.conf with
Code:
proxy_interfaces = 82.36.74.191
sendmail	/usr/local/sbin/sendmail
send-mail	/usr/local/sbin/sendmail
mailq		/usr/local/sbin/sendmail
newaliases	/usr/local/sbin/sendmail
and I still get the same error message when doing sendmail -bv root
Code:
Mar 10 08:21:21 FREEBSD_HOST sendmail[2425]: gethostbyaddr(192.168.0.115) failed: 1
Mar 10 08:21:21 FREEBSD_HOST sendmail[2425]: gethostbyaddr(192.168.0.120) failed: 1
Mar 10 08:21:21 FREEBSD_HOST sendmail[2425]: gethostbyaddr(192.168.0.125) failed: 1
when i type mail [email=myemail@gmail.com]myemail@gmail.com[/email] I get
from /var/log/maillog
Code:
Mar 10 08:34:57 FREEBSD_HOST sendmail[2570]: s2A8YvKf002570: from=admin, size=52, class=0, nrcpts=1, msgid=<201403100834.s2A8YvKf002570@FREEBSD_HOST.etsitservices.lan>, relay=root@localhost
Mar 10 08:34:57 FREEBSD_HOST postfix/smtpd[2571]: connect from localhost[127.0.0.1]
Mar 10 08:34:57 FREEBSD_HOST postfix/smtpd[2571]: E01484806C: client=localhost[127.0.0.1]
Mar 10 08:34:58 FREEBSD_HOST postfix/cleanup[2574]: E01484806C: message-id=<201403100834.s2A8YvKf002570@FREEBSD_HOST.home.lan>
Mar 10 08:34:58 FREEBSD_HOST sendmail[2570]: s2A8YvKf002570: to=myemail@gmail.com, ctladdr=admin (1001/1001), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30052, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as E01484806C)
Mar 10 08:34:58 FREEBSD_HOST postfix/qmgr[889]: E01484806C: from=<admin@FREEBSD_HOST.home.lan>, size=608, nrcpt=1 (queue active)
Mar 10 08:34:58 FREEBSD_HOST postfix/smtpd[2571]: disconnect from localhost[127.0.0.1]
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: warning: smtp_sasl_auth_enable is true, but SASL support is not compiled in
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: warning: TLS has been selected, but TLS support is not compiled in
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: E01484806C: to=<myemail@gmail.com>, relay=smtp.gmail.com[173.194.66.108]:587, delay=0.31, delays=0.14/0.03/0.12/0.02, dsn=5.7.0, status=bounced (host smtp.gmail.com[173.194.66.108] said: 530 5.7.0 Must issue a STARTTLS command first. t5sm48815618wjw.15 - gsmtp (in reply to MAIL FROM command))
Mar 10 08:34:58 FREEBSD_HOST postfix/cleanup[2574]: 428B34806E: message-id=<20140310083458.428B34806E@FREEBSD_HOST.home.lan>
Mar 10 08:34:58 FREEBSD_HOST postfix/bounce[2576]: E01484806C: sender non-delivery notification: 428B34806E
Mar 10 08:34:58 FREEBSD_HOST postfix/qmgr[889]: 428B34806E: from=<>, size=2718, nrcpt=1 (queue active)
Mar 10 08:34:58 FREEBSD_HOST postfix/qmgr[889]: E01484806C: removed
Mar 10 08:34:58 FREEBSD_HOST postfix/local[2577]: 428B34806E: to=<admin@FREEBSD_HOST.home.lan>, relay=local, delay=0.03, delays=0.01/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Mar 10 08:34:58 FREEBSD_HOST postfix/qmgr[889]: 428B34806E: removed
from email in my FREEBSD_HOST
Code:
Message 1:
From MAILER-DAEMON  Mon Mar 10 08:34:58 2014
Date: Mon, 10 Mar 2014 08:34:58 +0000 (UTC)
From: MAILER-DAEMON@FREEBSD_HOST.home.lan (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: admin@FREEBSD_HOST.home.lan

This is a MIME-encapsulated message.

--E01484806C.1394440498/FREEBSD_HOST.home.lan
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii

This is the mail system at host FREEBSD_HOST.home.lan.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<myemail@gmail.com>: host smtp.gmail.com[173.194.66.108] said: 530 5.7.0 Must
    issue a STARTTLS command first. t5sm48815618wjw.15 - gsmtp (in reply to
    MAIL FROM command)

--E01484806C.1394440498/FREEBSD_HOST.home.lan
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; FREEBSD_HOST.home.lan
X-Postfix-Queue-ID: E01484806C
X-Postfix-Sender: rfc822; admin@FREEBSD_HOST.home.lan
Arrival-Date: Mon, 10 Mar 2014 08:34:57 +0000 (UTC)

Final-Recipient: rfc822; myemail@gmail.com
Original-Recipient: rfc822;myemail@gmail.com
Action: failed
Status: 5.7.0
Remote-MTA: dns; smtp.gmail.com
Diagnostic-Code: smtp; 530 5.7.0 Must issue a STARTTLS command first.
    t5sm48815618wjw.15 - gsmtp

--E01484806C.1394440498/FREEBSD_HOST.home.lan
Content-Description: Undelivered Message
Content-Type: message/rfc822

Return-Path: <admin@FREEBSD_HOST.home.lan>
Received: from FREEBSD_HOST.home.lan (localhost [127.0.0.1])
        by FREEBSD_HOST.home.lan (Postfix) with ESMTP id E01484806C
        for <myemail@gmail.com>; Mon, 10 Mar 2014 08:34:57 +0000 (UTC)
Received: (from root@localhost)
        by FREEBSD_HOST.home.lan (8.14.7/8.14.7/Submit) id s2A8YvKf002570
        for myemail@gmail.com; Mon, 10 Mar 2014 08:34:57 GMT
        (envelope-from admin)
Date: Mon, 10 Mar 2014 08:34:57 GMT
From: System Administrator <admin@FREEBSD_HOST.home.lan>
Message-Id: <201403100834.s2A8YvKf002570@FREEBSD_HOST.home.lan>
To: myemail@gmail.com
Subject: test

my test email

--E01484806C.1394440498/FREEBSD_HOST.home.lan--

Hope I provided enough info
 
Re: Postfix email problem with Gmail

I see you're on an dynamic IP address and live in the UK. Can you get an static IP address? Can you find another ISP?
I'm American but some ISPs in the UK which I believe offer static addresses/let you unblock port 25 include AAISP, Zen, and Eclipse. I never tried them because I live in the US, and just read their marketing material.
 
Re: Postfix email problem with Gmail

neel said:
I see you're on an dynamic IP address and live in the UK. Can you get an static IP address? Can you find another ISP?
I'm American but some ISPs in the UK which I believe offer static addresses/let you unblock port 25 include AAISP, Zen, and Eclipse. I never tried them because I live in the US, and just read their marketing material.

No am on static IP address, I don't know if virgin would block port 25.. That's a good point. Is there a way to check without calling them?
 
Re: Postfix email problem with Gmail

fred974 said:
...and I still get the same error message when doing sendmail -bv root
Code:
Mar 10 08:21:21 FREEBSD_HOST sendmail[2425]: gethostbyaddr(192.168.0.115) failed: 1
...
Please let us know the settings for mydomain, myhostname, myorigin, and mydestination in your file /usr/local/etc/postfix/main.cf.

The respective section in my main.cf is the following – I only replaced my actual domain name with example.com:
Code:
# INTERNET HOST AND DOMAIN NAMES
mydomain                            = example.com
myhostname                          = mail.$mydomain
myorigin                            = $mydomain
mydestination                       = $mydomain, $myhostname, localhost

You need to make sure manually that all the corresponding entries in your main.cf do resolve correctly – replace example.com with your actual domain.

host example.com
Code:
example.com has address 12.345.678.90
example.com mail is handled by 10 mail.example.com.

host mail.example.com
Code:
mail.example.com has address 12.345.678.90

host localhost
Code:
localhost has address 127.0.0.1
localhost has IPv6 address ::1

What is the result of the reverse lookup of your IP address that failed with your postfix:
host 192.168.0.115

Does this resolve to an actual domain name? Why not? If not, how does Postfix come to know about it?

fred974 said:
... when i type mail [email=myemail@gmail.com]myemail@gmail.com[/email] I get
from /var/log/maillog
Code:
...
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: warning: smtp_sasl_auth_enable is true, but SASL support is not compiled in
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: warning: TLS has been selected, but TLS support is not compiled in
...

Note that Dovecot SASL is ONLY used for incoming SMTP, i.e. smtpd. If you need SASL for outgoing SMTP, i.e. smtp, then you need to compile Postfix with Cyrus SASL in addition to Dovecot SASL. Then you need to provide the smtp-authentication method, and the password file. The respective section in my main.cf looks like the following, however, I don't use gmail but my domain hosting provider (Strato Berlin) as mail relay.
Code:
# OUTGOING MAIL
relayhost                           = [smtp.strato.de]:submission
smtp_sasl_auth_enable               = yes
smtp_sasl_mechanism_filter          = digest-md5
smtp_sasl_password_maps             = hash:/usr/local/etc/postfix/relay-sasl-password

Finally, you didn't seem to compile Postfix with TLS support (the second error message). You need to compile Postfix with OpenSSL or alike.
 
Re: Postfix email problem with Gmail

fred974 said:
... I don't know if virgin would block port 25. That's a good point. Is there a way to check without calling them?

I suggest not to bother about outgoing port 25, and to use the submission port 587 for connecting your mail-relay:

Code:
...
relayhost  = [smtp.gmail.com]:submission
...

Obviously, you are already using 587.

fred974 said:
Code:
...
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: E01484806C: to=<myemail@gmail.com>, relay=smtp.gmail.com[173.194.66.108]:587, delay=0.31, delays=0.14/0.03/0.12/0.02, dsn=5.7.0, status=bounced (host smtp.gmail.com[173.194.66.108] said: 530 5.7.0 Must issue a STARTTLS command first. t5sm48815618wjw.15 - gsmtp (in reply to MAIL FROM command))
...

It would help you a lot, if you would read your actual error log. from the above line it so very clear that gmail is expecting a TLS connection, and that your Postfix is not able to provide it, because as the warning one line above states, it was not compiled with TLS support –– any more questions?
 
Re: Postfix email problem with Gmail

obsigna said:
fred974 said:
... I don't know if virgin would block port 25. That's a good point. Is there a way to check without calling them?

I suggest not to bother about outgoing port 25, and to use the submission port 587 for connecting your mail-relay:

Code:
...
relayhost  = [smtp.gmail.com]:submission
...

Obviously, you are already using 587.

fred974 said:
Code:
...
Mar 10 08:34:58 FREEBSD_HOST postfix/smtp[2575]: E01484806C: to=<myemail@gmail.com>, relay=smtp.gmail.com[173.194.66.108]:587, delay=0.31, delays=0.14/0.03/0.12/0.02, dsn=5.7.0, status=bounced (host smtp.gmail.com[173.194.66.108] said: 530 5.7.0 Must issue a STARTTLS command first. t5sm48815618wjw.15 - gsmtp (in reply to MAIL FROM command))
...

It would help you a lot, if you would read your actual error log. from the above line it so very clear that gmail is expecting a TLS connection, and that your Postfix is not able to provide it, because as the warning one line above states, it was not compiled with TLS support –– any more questions?

Thank you for the advised.. I tried what you suggested but still no luck :(
 
Re: Postfix email problem with Gmail

Did you install postfix from pkgng or ports? If you installed from ports, try this (as root):
Code:
cd /usr/ports/mail/postfix
make rmconfig
make config-recursive
make deinstall install clean
In the make config-recursive command, select TLS.

And can you telnet port 25? (like telnet mail.neelc.org 25)
 
Re: Postfix email problem with Gmail

Hi @obsigna,
Sorry its a I 'look but didn't see' scenario..Ill do what @neel sugested and add the TLS option.
@obsigna I'm not using a domain, just gmail in this scenario
 
Last edited by a moderator:
Re: Postfix email problem with Gmail

fred974 said:
... Ill do what @neel sugested and add the TLS option.

Don't forget to add Cyrus SASL, since this would be the next obstacle. Once gmail accepted the TLS connection in the first place, it will ask Postfix for authentication in the second stage, and per your setup Cyrus SASL is definitely needed for this.
 
Last edited by a moderator:
Back
Top