I have a website where the domain uses an external mail server (defined by mail.mydomain.com and the MX record). An example email address is johndoe@mydomain.com. Whenever the server sends a notification email to this user, it gets bounced with a message such as:

to=, relay=local, delay=0.03, delays=0.02/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "johndoe")

because it thinks the destination is localhost instead of mail.mydomain.com. Will reconfiguring Postfix take care of this issue? If so, what directives specifically need to be changed/added? And if not, what is the best way to resolve this?

Edit - Added postconf -n output:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = mydomain.com, localhost.localdomain, localhost
myhostname = mydomain.com
mynetworks = [::ffff:]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = 
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes


  • Can you please post the output of postconf -n to get better help? – Khaled Dec 18 '10 at 7:55
  • Sure, thanks. postconf -n output added above. – modulaaron Dec 18 '10 at 20:55
  • Are you sending the mail into the MTA as well? This looks to me like the 'To' in the envelope is just 'johndoe' and not 'johndoe@mycompany.com'. Also, is 'johndoe' a local account on this machine -- it doesn't look to me that you're doing virtual delivery, so you need to ensure you have accounts for everyone on the box. – jharley Dec 19 '10 at 15:37
  • johndoe@mycompany.com is an email address located at mail.mycompany.com, a remote mail server. When I send mail to this address from the web server, the problem is that it looks for this user on the web server localhost instead of on the remote mail server. The web server is only used to send mail - never to receive mail. – modulaaron Dec 19 '10 at 22:11

Problem solved by changing:

mydestination = mydomain.com, localhost.localdomain, localhost


mydestination = www.mydomain.com, localhost.localdomain, localhost

Given this is viewed many time, the working answer works with static domains, but is confusing regarding postfix syntax.

For outgoing service where the e-mail is being sent to an address of the same domain as the hostname

mydestination = $myhostname, localhost.$mydomain, $mydomain

is the recommended configuration string.

However the above link does not take into allowance the case raised by the question. so say your server is named www.sporting.events, you would need to configure:

myhostname = www.sporting.events
mydomain = www.sporting.events

to get mails not relayed to local

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.