4

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:

/etc/postfix/main.cf

# default options to allow relay via gmail
smtp_use_tls=yes
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

/etc/postfix/relayhost_maps

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

/etc/postfix/sasl_passwd

[smtp.gmail.com]:587  user-one-at-google@gmail.com: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?

3

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:

/etc/postfix/sasl_passwd

user-one@localhost       user-one-at-google@gmail.com:user-one-pass-at-google
user-two@localhost       user-two-at-google@gmail.com:user-two-pass-at-google
1
  • 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/… – Ryan Griggs May 28 '14 at 2:00

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.