Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a following setup: 1 postfix server: that needs to accept all emails for any subdomain on (*@* and delivers to mailman account and also send emails to any email account (gmail, yahoo, etc) including * 1 hosted exchange: for emails (*

Everything works in this setup except sending emails from to * ( If I have in mydomains.db file, then does not send out * emails and delivers locally. if I change it to * then it sends * emails to but now does not accept * emails and shows an error that Relay is not allowed (it should not be relaying and delivering to local maildir account).

Main requirement is to have accept mail for any subdomain and deliver emails for main domain to Can anyone please help me or point me towards right direction?

Any help is welcome.


command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mydestination = hash:/etc/postfix/mydomains
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
home_mailbox = Maildir/
smtpd_banner =

debug_peer_level = 2
debugger_command =
     xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
virtual_alias_maps = hash:/etc/postfix/virtual, pcre:/etc/postfix/virtual.pcre
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtp_sasl_security_options = noplaintext
#smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender-access
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/inbound-access,permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 25600000
transport_maps = hash:/etc/postfix/transport
message_size_limit = 20240000

virtual.pcre and virtual:

/(.*)@[^.]*\.example\.com$/ mailman


# demo   smtp:
# demo mail    smtp:
# Demo2  smtp:
# demo2 domain   smtp:


localhost       OK
mail.local  OK     OK
share|improve this question
You should provide your otherwise we won't have enough information to help you. – Ulrich Dangel Jul 19 '12 at 21:55
Thanks. Added to the OP – Iuri G. Jul 19 '12 at 22:14

1 Answer 1

up vote 0 down vote accepted

First of all i am not sure if this will work but i hope it will help get you started:

  1. Remove from mydomains as this postfix instance does not handle the mail for it directly.
  2. Add virtual_alias_domains = this should solve your subdomain issue
  3. Add relay_domains = and specify an explicit transport for, e.g: :[]
share|improve this answer
Thanks. I just tried on test server and outgoing email works fine. I did not specify explicit transport and it looks like it is picking up server from MX record correctly. I will be testing incoming email on our main server on monday and hopefully I dont get Relay Denied errors on incoming mail from untrusted network... P.S. How important is it to specify explicit transport? Thanks again. – Iuri G. Jul 20 '12 at 14:33
@IuriG. you don't need to specify an explicit transport if the mx record is correct but anyway why does receive mail from untrusted networks for if the mx record doesn't point to – Ulrich Dangel Jul 20 '12 at 15:06
It does not. My above comment was referring to emails. Usually when i changed in mydomains to, for some reason postfix would stop receiving emails from untrusted netwrok (for As if it was not supposed to receive them and was giving Relay Denied error. Hopefully virtual_alias_domain will work right for incoming email. – Iuri G. Jul 20 '12 at 15:29
thanks. works very well. just tested in production server – Iuri G. Jul 20 '12 at 22:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.