Ubuntu – Postfix problems sending mail to gmail addresses

emailpostfixUbuntu

I have just installed Postfix and while recieving email seems to work fine, I have trouble sending email.

When I send mail to an address provided by my ISP, the mail gets delivered successfully. The problems start when I send a mail to a gmail address.

When I check the mail queue, I can see the email is stuck:

myuser@My-Server:~$ mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
7580BB40C58      551 Sat Apr 23 18:30:27  myuser@mail.mydomain.nl
(connect to alt2.gmail-smtp-in.l.google.com[64.233.189.26]:25: Connection timed out)
                                         mydestination@gmail.com
-- 0 Kbytes in 1 Request.

You can see it says Connection timed out. The problems get confirmed when I check postfix.log:

Apr 23 18:30:27 My-Server postfix/pickup[11208]: 7580BB40C58: uid=1000 from=<myuser>
Apr 23 18:30:27 My-Server postfix/cleanup[12038]: 7580BB40C58: message-id=<20160423163027.7580BB40C58@mail.mydomain.nl>
Apr 23 18:30:27 My-Server postfix/qmgr[11209]: 7580BB40C58: from=<myuser@mail.mydomain.nl>, size=551, nrcpt=1 (queue active)
Apr 23 18:30:27 My-Server postfix/smtp[12040]: connect to gmail-smtp-in.l.google.com[2a00:1450:4013:c01::1a]:25: Network is unreachable
Apr 23 18:30:57 My-Server postfix/smtp[12040]: connect to gmail-smtp-in.l.google.com[74.125.136.26]:25: Connection timed out
Apr 23 18:31:27 My-Server postfix/smtp[12040]: connect to alt1.gmail-smtp-in.l.google.com[74.125.68.26]:25: Connection timed out
Apr 23 18:31:27 My-Server postfix/smtp[12040]: connect to alt1.gmail-smtp-in.l.google.com[2404:6800:4003:c02::1b]:25: Network is unreachable
Apr 23 18:31:57 My-Server postfix/smtp[12040]: connect to alt2.gmail-smtp-in.l.google.com[64.233.189.26]:25: Connection timed out
Apr 23 18:31:58 My-Server postfix/smtp[12040]: 7580BB40C58: to=<mydestination@gmail.com>, relay=none, delay=91, delays=0.17/0.01/90/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[64.233.189.26]:25: Connection timed out)

It says status=deffered and Connection timed out. It retries every few minutes automatically, and fails everytime.

My mail.cf files looks like this:

myhostname = mail.mydomain.nl

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

myorigin = /etc/mailname
mydestination = mail.mydomain.nl, My-Server, , localhost, mydomain.nl

relayhost = 
mynetworks = 127.0.0.0/8 192.168.1.0/24 10.8.0.1/32 [::1]/128 [fe80::]/64
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

inet_protocols = all

I have my own domain name and think I have configured its DNS settings correctly. I also think I have set the name correctly on my server, but I am not entirely sure. Please note I do not want to relay my mail through gmail servers, but just send mail to them.
The server runs Ubuntu Server 14.04 LTS.

If someone could help me with this problem, it would be greatly appreciated.

Best Answer

Can you reach any SMTP server beyond your ISP network?
Do you get SMTP greeting message using "telnet tests"?

telnet mx-host-name 25

NO => Maybe your ISP blocks outgoing connections to SMTP port to block outgoing spam.

Related Question