54

I am configuring Postfix and when validating by telnet and SMTP I got the status bounced error, unknown user:

Error log:

postfix/local[18718]: 4590D7DC0A51: to=myuser@mydomain.example, relay=local, delay=9.8, delays=9.8/0.01/0/0.04, dsn=5.1.1, status=bounced (unknown user: "myuser")

The "myuser" already exists, but with full domain name: myuser@mydomain.example.

User Validation:

 postmap -q myuser@mydomain.example mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf

Output is: "1" - so I guess it is OK.

My postfix Configuration:

root# postconf -n:
append_at_myorigin = yes
biff = no
config_directory = /etc/postfix
default_destination_concurrency_limit = 1
delay_warning_time = 8h
disable_vrfy_command = yes
dovecot_destination_concurrency_limit = 1
dovecot_destination_recipient_limit = 1
enable_original_recipient = yes
local_destination_concurrency_limit = 1
maximal_queue_lifetime = 6d
mydestination = mydomain.example
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated
smtpd_delay_reject = no
smtpd_hard_error_limit = 10
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, reject_invalid_hostname
smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_sender_domain,             reject_unknown_recipient_domain, reject_unlisted_recipient, reject_unauth_destination, reject_unauth_pipelining
smtpd_sender_restrictions = permit_mynetworks, reject_unknown_sender_domain
smtpd_soft_error_limit = 5
strict_rfc821_envelopes = yes
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = dovecot
Braiam
  • 1
  • 11
  • 47
  • 78
Radim Burget
  • 1,456
  • 2
  • 20
  • 39

4 Answers4

124

you have added mydestination = mydomain.example and so the valid users for mydomain.example will be searched in local_recipient_maps. It is very clear from the logline that local delivery agent is selected to deliver the mail, as local domain class matched. See postfix address classes for more help

Modify your main.cf like below

#/etc/postfix/main.cf
mydestination =
# set to localhost localhost.$mydomain or remove mydomain.example for now
# Ensure that postmap -q mydomain.example mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf is returning mydomain.example and
# postmap -q myuser@mydomain.example mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf succeeds
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
clement
  • 3,289
  • 2
  • 17
  • 11
  • I was configuring use of AWS SES with SMTP and was noticing local delivery. This fixes my issue. It's so weird its not mentioned in the AWS docs (maybe I just didn't find it...). Thanks! – arod Jun 12 '20 at 21:04
  • I don't have /etc/postfix/mysql-* files, but changing mydestination worked for me. Thanks! – mkumar118 Jan 20 '21 at 13:59
3

Open /etc/postfix/main.cf, look for the mydestination field and change it's value to the below

mydestination = localhost, localhost.localdomain

Don't forget to run sudo postfix reload afterwards

aphoe
  • 2,586
  • 1
  • 27
  • 31
2

Use following settings in /var/postfix/main.cf

myorigin = localhost
myhostname = <your_host_name>
mydestination = localhost.$mydomain, localhost, localhost.localdomain

followed by:

sudo postmap /etc/postfix/virtual
sudo service postfix restart
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Janib Soomro
  • 446
  • 6
  • 12
  • This worked for me, except the `postmap /etc/postfix/virtual`, that returned `postmap: fatal: open /etc/postfix/virtual: No such file or directory` – Still OK for me – Jimmy Adaro Feb 11 '20 at 19:25
0

For someone else, when I set mydestination=mydomain.example. Postfix show warning do not list domain mydomain.example in BOTH mydestination and virtual_mailbox_domains. So I set it relayhost = mydomain.example

My postfix version: 3.1.0 (postconf -d | grep mail_version)

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
tuananh
  • 747
  • 8
  • 17