2

I recently have been moving from Centos to Debian. A few weeks ago I setup up a server with Postfix / Dovecot and it went fine. I'm doing the same again today but keep getting bounces with the error:

Recipient address rejected: User unknown in local recipient table (in reply to RCPT TO command)

This happens if I send remotely or via sendmail locally.

The users are setup in /etc/postfix/virtual-mailbox as normal; e-mail address then a space then the domain. I have run postmap /etc/postfix/virtual-mailbox to create the db file successfully.

This is the result of postconf -n showing my config changes:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = ipv4
local_recipient_maps = unix:passwd.byname $alias_maps
mail_owner = postfix
mailbox_size_limit = 1073741824
mailq_path = /usr/bin/mailq
message_size_limit = 10485760
mydomain = domain.net
myhostname = domain.net
mynetworks = 127.0.0.0/8, 10.0.0.0/24
mynetworks_style = subnet
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases
sendmail_path = /usr/sbin/postfix
setgid_group = postdrop
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = may
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_mynetworks,reject_invalid_hostname, reject_unknown_recipient_domain,reject_unauth_destination,reject_rbl_client sbl.spamhaus.org,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.domain.net/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.domain.net/privkey.pem
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
unknown_local_recipient_reject_code = 550
virtual_alias_domains = virtual.host
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_gid_maps = static:20000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = domain.net
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:20000

I can see no other errors in the logs just the same Recipient address rejected: User unknown in local recipient table.

Although it's possible I still haven't got Clam AV / Amavis and Dovecot setup 100% correctly yet, this reject seems like a purely Postfix problem. I can connect to the account's mailbox by the way, so Dovecot appears to be working.

Kline
  • 247
  • 1
  • 5
  • 17

2 Answers2

1

Postfix - in the default configuration - assumes that mail destined for the mail server gets handled locally. So if you are receiving mail for mailbox@mydomain.example, and your mail server is called mydomain.example, that gets handled locally. This is how you got the "in local recipient table" error message.

You can see that you are using this default by letting postconf display & expand that setting:

# postconf mydestination
mydestination = $myhostname, localhost.$mydomain, localhost
# postconf -x mydestination
mydestination = mydomain.example, localhost.mydomain.example, localhost

Configure a proper mail server host name & domain. Ideally, not just the second-level mydomain.example but with a name like mx2.mydomain.example. The settings myhostname and mydomain should typically not equal.

Of course, you can also change which domains are handled locally by configuring mydestination - removing from that setting those destinations handled via virtual i.e. via Dovecot. In fact, it is perfectly valid to hand all mail to a virtual transport and keep mydestination empty.

In any case, do setup a hostname though, many recipients strongly prefer to receive mail from servers that know who they are. That this indicate that the person who set them up was willing and able to configure a hostname and register its address/name pair in DNS, in both directions.

anx
  • 8,963
  • 5
  • 24
  • 48
0

The answer to this was to make mydestination = localhost and therefore avoid $myhostname / $domain being handled locally. It was not an issue as anx suggested to have $myhostname & $domain be equal or for that value to be the main domain name e.g example.domain.

Of course this setup requires virtual_mailbox_domains to include the domain so it can be handled as a virtual mailbox (as I had), but crucially the domain must not be included in virtual_alias_domains or this produces a further error.

Kline
  • 247
  • 1
  • 5
  • 17
  • `mydestination` is not the only setting that by default references `myhostname` &/ `mydomain` with the expectation that those are setup following standard practices. Run `postconf | grep myhostname` and `postconf | grep mydomain` to see other uses. – anx Apr 30 '21 at 16:36