0

I have configured Postfix to send all emails to a smart host, and it can work for weeks without problems. But every now and then it stops working and shows messages such as these in the log (the first two lines are for the last successful sending, and the last two are the first message that fails to go out):

Nov 24 20:05:30 nextcloud postfix/smtp[443568]: 3882C1B5D8A: to=<xxxxxx>, relay=relay.grnet.gr[83.212.2.185]:587, delay=2.3, delays=1.3/0/0.02/1, dsn=2.0.0, status=sent (250 OK id=1oyGbJ-0001PM-H2)
Nov 24 20:05:30 nextcloud postfix/qmgr[193834]: 3882C1B5D8A: removed
Nov 24 20:44:43 nextcloud postfix/postfix-script[1563]: warning: symlink leaves directory: /etc/postfix/./makedefs.out
Nov 24 20:44:46 nextcloud postfix/postfix-script[1751]: warning: /var/spool/postfix/etc/resolv.conf and /etc/resolv.conf differ
Nov 24 20:44:46 nextcloud postfix/postfix-script[1772]: starting the Postfix mail system
Nov 24 20:44:46 nextcloud postfix/master[1774]: daemon started -- version 3.4.13, configuration /etc/postfix
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: connect from localhost[127.0.0.1]
Nov 24 21:05:19 nextcloud postfix/smtpd[4252]: E76A51B5819: client=localhost[127.0.0.1]
Nov 24 21:05:20 nextcloud postfix/cleanup[4257]: E76A51B5819: message-id=<4fd8e1188978e71021cd47f62d050d57@swift.generated>
Nov 24 21:05:20 nextcloud postfix/smtpd[4252]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Nov 24 21:05:20 nextcloud postfix/qmgr[1776]: E76A51B5819: from=<xxxxxx>, size=37076, nrcpt=1 (queue active)
Nov 24 21:05:21 nextcloud postfix/smtp[4258]: E76A51B5819: to=<xxxxxx>, relay=none, delay=0.36, delays=0.33/0.03/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=relay.grnet.gr type=MX: Host not found, try again)

Subsequently it remains in this status for ever (it was once stuck for about three weeks until I found out); all messages fail and remain in the queue. When I restart it, it works again, sends all the deferred messages, and works happily until the next time the problem occurs.

How can I configure it to be resilient and not require a restart?

I'm using Postfix 3.4.13 in Ubuntu 20.04. Here is /etc/postfix/main.cf:

myorigin = /etc/mailname
biff = no
compatibility_level = 3
relayhost = relay.grnet.gr:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = loopback-only
virtual_alias_maps = hash:/etc/postfix/virtual
masquerade_domains = grnet.gr
2
  • Probably your DNS resolution breaks? Are there any correlations with other things that happen on the server? Also, how exactly did you configured a smart host, can we see your configuration? Jan 25 at 9:52
  • @NikitaKipriyanov I added the configuration to the question. It's possible that the DNS breaks. Even if it does, it always fixes itself. But Postfix remains broken until restarted. Shouldn't it come back up when whatever problem goes away? Jan 25 at 11:20

1 Answer 1

1

The way you specified relayhost makes it to do a MX lookup on the specified name and use that name to look up the address of the server where to connect to 587. This is why it says "MX: Host not found, try again".

If relay.grnet.gr is the literal name of the MX server (and not a domain name where MX records exist that specify MX servers), put it into square brackets to suppress this MX lookup and use A record:

relayhost = [relay.grnet.gr]:587

Look also man 5 postconf

2
  • Thanks! So the strange thing isn't that it was sometimes failing—it's that sometimes it was working. Go figure... Jan 25 at 14:25
  • Yes, I was about to write the same :) Jan 26 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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