2

On CentOS 7 Linux I run Drupal, which requires users to confirm their mail addresses.

I have modified the postfix config files in the following way:

/etc/postfix/generic:

@www.localdomain noreply@preferans.de

/etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

This results in Drupal sending registration mails to new users which contains the headers:

From: noreply@preferans.de     <--- non-existing address at my domain
Reply-To: First.Last@gmail.com <--- my private mail address

This works well (better than earlier, when I set From: to my Gmail address and Gmail was thinking my website was spamming others), but I have a problem:

I do not want to accept any mail addressed to anyone @preferans.de anymore (too much SPAM was pouring in), so I have deleted the MX records in the DNS entry of my server and closed the port 25 by iptables.

Now when a new Drupal user enters a fake address, the registration mail bounces back to noreply@preferans.de but my postfix installation can not deliver it:

/var/log/maillog:

Aug 16 18:20:44 www postfix/master[1006]: daemon started -- version 2.10.1, configuration /etc/postfix
Aug 16 22:29:20 pref postfix/cleanup[9031]: 785952C03A8: message-id=<20170816202920.785952C03A8@pref.localdomain>
Aug 16 22:29:20 pref postfix/bounce[9033]: 5B56F2C03A7: sender non-delivery notification: 785952C03A8
Aug 16 22:29:20 pref postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:29:20 pref postfix/qmgr[24449]: 5B56F2C03A7: removed
Aug 16 22:29:22 pref postfix/smtp[9009]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:29:22 pref postfix/smtp[9009]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=1.5, delays=0/0/1.5/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 22:38:51 pref postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:38:51 pref postfix/smtp[9208]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:38:51 www postfix/smtp[9208]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=571, delays=571/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 22:48:51 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:48:51 www postfix/smtp[9393]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:48:51 www postfix/smtp[9393]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=1171, delays=1171/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 23:08:51 www postfix/qmgr[24449]: CF37F2C039F: from=<noreply@preferans.de>, size=1234, nrcpt=1 (queue active)
Aug 16 23:08:51 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 23:08:51 www postfix/smtp[9797]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 23:08:51 www postfix/smtp[9797]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=2371, delays=2371/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 23:08:51 www postfix/smtp[9796]: connect to gamai.com[67.227.226.241]:25: Connection refused
Aug 16 23:08:51 www postfix/smtp[9796]: CF37F2C039F: to=<vs20132013@gamai.com>, relay=none, delay=4588, delays=4588/0.01/0.13/0, dsn=4.4.1, status=deferred (connect to gamai.com[67.227.226.241]:25: Connection refused)
Aug 16 23:48:52 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 23:48:52 www postfix/smtp[10420]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 23:48:52 www postfix/smtp[10420]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=4772, delays=4772/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)

And the queue fills up:

# sudo mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
CF37F2C039F     1234 Wed Aug 16 21:52:22  noreply@preferans.de
                 (connect to gamai.com[67.227.226.241]:25: Connection refused)
                                         vs20132013@gamai.com

785952C03A8     3262 Wed Aug 16 22:29:20  MAILER-DAEMON
                (connect to preferans.de[88.99.244.39]:25: Connection refused)
                                         noreply@preferans.de

BD4222C03B6     1219 Thu Aug 17 07:48:48  noreply@preferans.de
(host mx.yandex.ru[87.250.250.89] said: 451 4.5.1 The recipient <ebotstoreru@yandex.com> has exceeded their message rate limit. Try again later. 1502957639-8f63s3727h-Dw8G1QLj (in reply to end of DATA command))
                                         ebotstoreru@yandex.com

-- 6 Kbytes in 3 Requests.

My question is please:

How to configure my postfix installation, so that it drops not delivered mails immediately (but still comes through grey-listing)?

Finally here is the current postconf -n output:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_generic_maps = hash:/etc/postfix/generic
unknown_local_recipient_reject_code = 550
Alexander Farber
  • 714
  • 4
  • 16
  • 38
  • 1
    Add a "blacklist" as `check_recipient_access` in postfix `main.cf`. – Lenniey Aug 17 '17 at 08:30
  • Do you mean, that I should put `@preferans.de REJECT` into [/etc/postfix/access](http://www.postfix.org/access.5.html) file? Or maybe `DISCARD`? Will that work ok with grey listing? I.e. my Drupal sents registration mail and the recipients mailbox says: *try again later*, so I `DISCARD/REJECT` and thus never deliver that registration mail to a valid address. – Alexander Farber Aug 17 '17 at 12:25
  • 1
    If you reference your access file in your config as `check_recipient_access`, then yes. Or add another, depends on what you like more. The `REJECT` will look something like this in your logs: `Recipient address rejected: domain rejected;`. It won't work with greylisting, as you `REJECT` _all_ attempts to this domain. – Lenniey Aug 17 '17 at 12:38
  • Unfortunately I look at [main.cf](http://www.postfix.org/postconf.5.html) and still do not understand what to put there... My question is how to discard bounced mails sent from `noreply@preferans.de` to fake mail addresses. But `check_recipient_access` seems to apply to servers with opened port 25 (which is not my case). – Alexander Farber Aug 17 '17 at 12:48
  • ? If you don't have port 25 open, nothing will _ever_ be received on this server. I think I misunderstood you... – Lenniey Aug 17 '17 at 12:56
  • Yes, nothing is received. My server sents only (the Drupal registration confirmation mails). However the outgoing queue grows, because some new users submit fake mail addresses. – Alexander Farber Aug 17 '17 at 13:01
  • 2
    Ah, now I get it. You're talking about [backscattering](http://www.postfix.org/BACKSCATTER_README.html). Use the info in the link to instruct your server how to handle these mails. – Lenniey Aug 17 '17 at 13:07
  • Unfortunately no, it is not about backscattering as noone fakes my return address. They just provide fake addresses a Drupal registration form, the mail bounces and my postfix keeps trying to deliver it... – Alexander Farber Aug 17 '17 at 19:30
  • No, you got that wrong. Look at your logs. It's almost always `from=<>` and `to=noreply@preferans.de`, which is, backscattering. It's trying to bounce _to_ your address. – Lenniey Aug 17 '17 at 19:36
  • I don't think so, since my port 25 is closed :-) – Alexander Farber Aug 17 '17 at 20:05
  • Dude, yes... I know. Would you just have a look at your logs? Connection refused from _your_ server, which is logical, considering you closed your SMTP port. Check my link... – Lenniey Aug 17 '17 at 20:10

1 Answers1

0

Solution for me has been to set

bounce_queue_lifetime = 2d

in /etc/postfix/main.cf to decrease the lifetime of bounced messages to 2 days

Alexander Farber
  • 714
  • 4
  • 16
  • 38