12

I followed these instructions in order to send mail and here's the Postfix log:

Sep 26 00:46:24 tshepang postfix/smtpd[5728]: 8EE2464931: client=localhost[127.0.0.1]
Sep 26 00:47:44 tshepang postfix/cleanup[5810]: 8EE2464931: message-id=<20110925224624.8EE2464931@tshepang>
Sep 26 00:47:44 tshepang postfix/qmgr[5772]: 8EE2464931: from=<tshepang@gmail.com>, size=350, nrcpt=1 (queue active)
Sep 26 00:48:04 tshepang postfix/smtp[5859]: 8EE2464931: to=<tshepang.test@gmail.com>, relay=none, delay=127, delays=107/0.01/20/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)
Sep 26 00:48:39 tshepang postfix/smtpd[5728]: disconnect from localhost[127.0.0.1]

Also, this may be relevant (from "/etc/postfix/main.cf"):

myhostname = tshepang
mydestination = tshepang, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = all
inet_protocols = all

I am running this on Debian 6.

tshepang
  • 65,642
  • Check your /etc/resolv.conf for invalid/non-responding resolvers. Try to do a host gmail.com; see if you get results. – laebshade Sep 25 '11 at 23:46
  • host gmail.com gives gmail.com has address 74.125.233.24 on the line, and then ;; connection timed out; no servers could be reached on the second. But it's strange because I can ping it. – tshepang Sep 26 '11 at 00:23
  • 3
    How about host -t mx gmail.com ? You're right, though, this is somewhat odd. – Shadur-don't-feed-the-AI Oct 20 '11 at 13:15
  • 1
    Another thought: can you add your /etc/resolv.conf to the question? – Shadur-don't-feed-the-AI Oct 20 '11 at 13:21
  • relayhost is empty? I found that you should comment it out if you do not have any relayhost. Apart from that you are getting no MX-record from DNS. Try what Shadur suggests... – Nils Oct 20 '11 at 20:48
  • @Nils "relay=none" -- postfix already recognizes there's no relay specified so it tries to send to the primary MX – Shadur-don't-feed-the-AI Oct 21 '11 at 13:52
  • ... and it seems there is no MX-record. – Nils Oct 21 '11 at 21:37
  • 1
    Yeah. Signs point to a dodgy resolv.conf, possibly due to network-manager or resolvconf not quite playing ball. – Shadur-don't-feed-the-AI Oct 22 '11 at 07:32
  • Boosting a couple questions mentioned in comments that might help figure out what's going on: - Can you add your /etc/resolv.conf to the question? The output you describe from host gmail.com is a bit suspicious and could indicate an issue with your nameserver. - What, if any, response do you get from the command host -t mx gmail.com ? - Have you successfully sent mail to other systems from this computer? - Does your ISP have some kind of explicit policy that requires you to use their server as mail relay? If they do, a firewall blocking MX lookup requests might explain the weird behavior – Shadur-don't-feed-the-AI Oct 25 '11 at 07:06
  • I agree with this. It looks more like a DNS issue than a problem with Postifx (especially because of the no servers could be reached error from host). – bahamat Jun 21 '12 at 18:48

7 Answers7

7

I used to have the same problem:

root@medusa:~# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
079AC700080B      357 Wed Apr  3 13:47:47  root@medusa.yyyy.cz
(Host or domain name not found. Name service error for name=xxxx.cz type=MX: Host not found, try again)
                                         hmls@xxxx.cz

..

root@medusa:~# host -t MX xxxx.cz
xxxx.cz mail is handled by 10 e2sgw01.xxxx.cz.
xxxx.cz mail is handled by 10 e2sgw02.xxxx.cz.

..

root@medusa:~# telnet e2sgw01.xxxx.cz. 25
Trying 217.77.161.168...
Connected to e2sgw01.xxxx.cz.
Escape character is '^]'.
220 e2sgw01.xxxx.cz ESMTP Postfix

The problem was in /var/spool/postfix/etc/resolv.conf file (the chrooted one). Have a look at it.

tshepang
  • 65,642
tloudev
  • 71
2

Try to disable the chroot property so that its not changerooted the /etc/postfix/master.cf as documented here

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd

to

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
2

I able to resolve it by telling to Postfix to use Google DNS , right after Installing postfix:

echo 'nameserver 8.8.8.8' >> /var/spool/postfix/etc/resolv.conf
ADV-IT
  • 219
  • 2
  • 3
1

As @Shadur pointed out, this issue could be due to your ISP (or the network where your server is installed). If there is a security restrictions on the SMTP port (port number 25), MX servers cannot by reached via this port.

You could try to use the SMTP over SSL port (ssmtp, port number 465) instead. To do this, edit the /etc/postfix/master.cf file, comment the smtp line and add a ssmtp line instead :

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
#smtp      inet  n       -       -       -       -       smtpd
ssmtp      inet  n       -       -       -       -       smtpd

To check that this post is recognized with this name on your machine, you can do :

$>cat /etc/services | grep smtp
smtp        25/tcp      mail
ssmtp       465/tcp     smtps       # SMTP over SSL
1

It look like you are behind a proxy : gmail.com address is resolved, but the ping command does not succeed. You can try to connect directly gmail's SMTP with :

nc -w 1 gmail.com 25 ; echo $?

if it echoes "1", you can't connect, probably cause of security filtering.

Arcadien
  • 1,585
1

In my case postfix starts up before the system has finished network initialization. So the /var/spool/postfix/etc/resolv.conf is empty.

When I restart postfix, it is no longer empty.

sudo systemctl restart postfix

After that the mail queue slowly drains.

-1
mkdir /var/spool/postfix/etc
cp /etc/resolv.conf /var/spool/postfix/etc/
user1133275
  • 5,574
  • Your answer is a bit terse and could be improved by explaining the issue, i.e., the underlying cause of the problem and why your solution correctly would resolve it for the user in the question. – Kusalananda May 25 '23 at 17:14