6

How can I stop Postfix from accepting mail to local-users @ my-FQDN from the outside world?

$ hostname -f
hostname.example.com

Postfix is accepting mail to any-local-user at my-FQDN. So we'll use [email protected] as the example local user I want to stop receiving mail for from the outside world.

I have a pretty basic Postfix/Dovecot/SASL/LDA setup, but let me share some of the details.

  • Receive mail for virtual local domains/users on :25
  • Virtual users send mail on :587 authenticated via Dovecot SASL

I've tried reversing users in /etc/aliases and Postfix's virtual_alias_maps.cf, but no luck. I've run newaliases and postmap after updating them.

#/etc/aliases:
#root: [email protected]

#/etc/postfix/virtual_alias_maps.cf:
root [email protected]

I think I have FOUR* (updated) choices left...

  1. In postfix/main.cf, mess with mydestination. I'm pretty sure I need to keep my FQDN here, so I don't think removing it is a good option. EDIT: Yes, although removing your FQDN from mydestination disables the outside world from sending mail to local users, this is not the proper way to disable it because that hoses other things.
  2. In postfix/main.cf, is there a setting for smtpd_recipient_restrictions to disable this? I can't find one in the docs.
  3. Hope that someone reads this who knows the right way.

Here is the relevant part of my Postfix main.cf:

myhostname = hostname.example.com
mydomain = example.com
mydestination = $myhostname, localhost.$mydomain, localhost

smtpd_recipient_restrictions =
    reject_unknown_recipient_domain,
    reject_non_fqdn_recipient,
    reject_unauth_destination,
    permit_mynetworks,
    permit

Here is the relevant part of my Postfix master.cf:

submission inet n       -       -       -       -       smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_recipient_restrictions=
     reject_unknown_recipient_domain,
     reject_non_fqdn_recipient,
     permit_sasl_authenticated,
     reject

P.S. Here is the HowTo I took a lot of my setup from: VirtualUserFlatFilesPostfix

2 Answers 2

4

Just remove $myhostname from mydestination and restart postfix

1
  • thanks, I m not the OP but had the same question, and i m sure your answer, even if short, is the best one !
    – neofutur
    Oct 26, 2014 at 19:31
1

You mention smtp_recipient_restrictions, have you actually tried adding the line check_recipient_access hash:/etc/postfix/recipient_access?

Place it as the first line before reject_unknown_recipient_domain, then in /etc/postfix/recipient_access add the line:

[email protected] REJECT

(don't forget to postmap /etc/postfix/recipient_access)

BTW, the postmaster address should always be available, but I have never seen an RFC that said that root had to be available, although I haven't read every single RFC that relates to SMTP.

5
  • I have no doubt that this will work, but there's something else fundamentally wrong with my setup.
    – Jeff
    Jul 8, 2013 at 15:25
  • What would that be exactly? You don't want to accept mail @your.fqdn.com ?
    – NickW
    Jul 8, 2013 at 15:29
  • I think the problem is my smtpd_recipient_restrictions=...,permit in my main.cf. My understanding of postmaster is that RFC wants it to be available at the localdomain level, not my.fqdn. I could be wrong about that, however. To answer your question, I don't want to receive any mail at my.fqdn.
    – Jeff
    Jul 8, 2013 at 15:44
  • Your postmaster address should be available on all domains, as it is the contact for malfunctions/problems, etc. This is one of the RFCs listing the ones that should be available : ietf.org/rfc/rfc2142.txt
    – NickW
    Jul 8, 2013 at 15:48
  • RFC 822 lists more info, but this should be of more interest to you: This standard specifies a single, reserved mailbox address (local-part) which is to be valid at each site. the local-part means to the left of the @
    – NickW
    Jul 8, 2013 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .