I recently noticed when I add an alias to a Gmail account they ask me for a remote SMTP server, username and password. Then, whenever I try to send an email using that alias it gets relayed by Gmail to the provided SMTP server.
Is there a way I can accomplish this setup on a Postfix install?
To clarify, on my server there's a virtual user [email protected]
(with the aliases: [email protected]
and [email protected]
) if he sends an email:
- With a
from
address of[email protected]
=> server will do the default delivery; - With a
from
address of[email protected]
=> server will relay email usingsmtp.xpto.com
(with proper credentials); - With a
from
address of[email protected]
=> server will relay email usingsmtp.corpx.com
(with proper credentials);
Ideally it would be nice If I could have a MySQL table with the external alises (for every virtual user) containing the external SMTP server domain, port, username and password. => This way I could setup a small web interface so my users could all their own external alises...
Thank you.
I guess you can achieve this by tuning the
sender_dependent_default_transport_maps
orsender_dependent_relayhost_maps
Postfix parameters. For example:This example uses static hash tables. If your Postfix installation supports mysql_table(5), you can use MySQL queries instead.
I am unable to test this solution now. I hope it works.