I currently have postfix configured so that all users get relayed by the local machine with the exception of one user that gets relayed via gmail. To that extent I've added the following configuration:


# default options to allow relay via gmail
smtp_sasl_auth_enable = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous

# map the relayhosts according to user 
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_maps

# keep a list of user and passwords
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd


user-one@localhost   [smtp.gmail.com]:587


[smtp.gmail.com]:587  [email protected]:user-one-pass-at-google

I know I can map multiple users to multiple passwords using smtp_sasl_password_maps but that would mean that all relay would be done by gmail where I specifically want all relay to be done by the localhost with the exception of some users.

Now I would like to have a user-two@localhost (etc) relay via google with their own respective passwords. Is that possible?

1 Answer 1


Set parameter smtp_sender_dependent_authentication to yes. Then you can user sender address as lookup key for smtp_sasl_password_maps.

References: official documentation and this page

In practical terms what you need to do is simply change the key in your sasl_passwd to user based. As per your example just add both users to the relayhost_maps file and alter the following file:


user-one@localhost       [email protected]:user-one-pass-at-google
user-two@localhost       [email protected]:user-two-pass-at-google
  • Why not use the 'virtual' file (/etc/postfix/virtual) and map the email address (which is considered an alias) to the desired recipients (which relays the message to all). You can enter multiple recipients for an address by simply placing a space between recipients, then postfix will relay all incoming messages to that user to all listed recipients . see serverfault.com/questions/183474/… May 28, 2014 at 2:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .