0

I'am searching for a way to bypass some accounts to a diffrent Mailserver then postfix. So some accounts should exist on the postfix server but anything else should be transport to a second SMTP Server. For that I setup a new centos 7 and install postfix with yum install postfix. In the defaultconfig I add transport_maps and for a simple test I add example.com in transport_maps with the destination Mailserver. But in case I send a Mail to userX@example.com postfix told me the account doesnet exist.

Postfix only accept Mails for known user so I create a alias in /etc/aliases userX: trash and the Mail will be transport to the destination SMTP Server. My Issue is that I do not know all the aliases from the Destination SMTP Server so I cant add all aliases to aliases.db is there a Option to accept all user on postfix for a known domain?

For a trivial example I need to transport all user to a diffrent SMTP Server.

#postconf -n
alias_database = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, example.com
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550

And my /etc/postfix/transport looks like:

example.com smtp:smtp.local

UPDATE As mentioned below I try to solve the issue with fallback_transport. I had updated my main.cf with

fallback_transport = relay
fallback_transport_maps = hash:/etc/postfix/transport

and the content of /etc/postfix/transport is

example.com smtp:smtp.local
*           smtp:smtp.local

but with this config the issue is the same. The user doestn exist so postfix told me the user doesnt exist. If I delete the example.com URL from mydestination the behavior is that the mail to user@example.com is in the mailq

1

You have to use either fallback_transport or luser_relay.

From: http://www.postfix.org/postconf.5.html

fallback_transport (default: empty)

Optional message delivery transport that the local(8) delivery agent should use for names that are not found in the aliases(5) or UNIX password database.

luser_relay (default: empty)

Optional catch-all destination for unknown local(8) recipients. By default, mail for unknown recipients in domains that match $mydestination, $inet_interfaces or $proxy_interfaces is returned as undeliverable.

To consider:

The precedence of local(8) delivery features from high to low is: aliases, .forward files, mailbox_transport_maps, mailbox_transport, mailbox_command_maps, mailbox_command, home_mailbox, mail_spool_directory, fallback_transport_maps, fallback_transport and luser_relay.

  • With luser_realy I only can send all mails to a specific user as I understood and with fallback_transport I doesnt work. For fallback_transport = relay and fallback_transport_maps = hash:/etc/postfix/transport with entry example.com smtp:smtp.local the Mail will reject only if I delete example.com from mydestination. And If deleted from mydestination the mail wont relay to smtp.local but is still in the mailq. I update the question with the config – kockiren May 9 at 12:03
  • postfix.1071664.n5.nabble.com/… This seems to suggest you need to use virtual_alias_maps and explicitly define each user in the local server and then a catch-all address that gets rewritten to the domain of the second server. If that domain is not publicly routable you will have to define it in transport_maps. Not sure if there's a better solution. – Bangaio May 10 at 3:24
  • Yes, that's the way I do for now. But with virtual_alias_maps I need to know all the aliases, that's difficult but not impossible. The Way to use a fallback relay would be much better because I know exactly all the User for the postfix system. – kockiren May 10 at 5:41
  • 1
    Just tried it using luser_relay = $user@example2.com and local_recipient_maps = . Any user that doesn't exist in the local server (after aliasing) gets redirected to example2.com. Is this what you need? – Bangaio May 11 at 3:05

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.