One of the services my company provides is scanning mail for spam and viruses, and then forwarding that scanned mail to their own servers (typically located on a DSL/cable line). We've been doing this with sendmail for quite awhile, but are getting ready to move to a postfix-based system.
What I'm having a problem with is this. We have a client (let's call him Joe Blow) who has two businesses, example1.com and example2.com. He has an account on each jb...@example1.com and jo...@example2.com . However, he doesn't want to actually receive mail at example2.com. So I need to redirect mail from jo...@example.com to jb...@example1.com . I'm doing this in sendmail using the ldap_routing m4 macros. However, everything I've read on Postfix is about either local delivery (using the aliases file) or relaying using the relay_recipients database. Can somebody give me the quick-and-easy answer or at least point me to the right terminology I can Google so I can get this resolved?
Austin
Yes, postfix will alias to an outside source, but only if it would otherwise be delivered locally. I just tried this and it gave me an error message of
postalias: warning: /etc/mail/aliases, line 48: name must be local
Since mail to this address wouldn't be delivered locally, there needs to be another way besides the aliases file.
Anyone? Anyone? Buhler? Buhler?
I believe virtual users is what you are looking for:
http://www.postfix.org/VIRTUAL_README.html#forwarding
Brad Crotchett
br...@bradandkim.net
http://www.bradandkim.net
I've read that, too, but they give no examples like I need, and the man page says it is
- to redirect mail for one address to one or more addresses
- to implement virtual alias domains where _all_ addresses are aliased to addresses in other domains
(emphasis mine)
I still want to be able to send jb...@example1.com to jo...@example2.com , but I also have other users that need to be delivered normally (incoming mail for jsm...@example1.com still needs to go to jsm...@example1.com on example1.com's server, and ja...@example2.com still needs to go to ja...@example2.com on example2.com's server) - we are just scanning it and forwarding it in these cases.
Since "virtual aliasing is recursive" (also quoted from their man page), it seems to me that I could indeed forward mail from jb...@example1.com to jo...@example2.com, but jsm...@example1.com then would not get relayed.
I may try this out anyway, but this server is live on a couple of domains, and I really don't want to drop any mail on the floor, so it would have to be late at night, when 99% of the mail is spam anyway. :-)
Within a given domain you can have some accounts forwarded to a different
address on another domain and some accounts just sent to the original
address. I do this quite a bit. My difference is that Postfix does all
it's lookups in a db rather than hash files (much easier user
administration) but it amounts to the same thing.
Mind giving me an excerpt?
Sure. In main.cf I have the following pertinent directives:
<snip>
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-local_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual.cf
virtual_transport = lmtp:unix:/var/lib/imap/socket/lmtp
virtual_alias_maps = mysql:/etc/postfix/mysql-aliases.cf,
mysql:/etc/postfix/mysql-virtual.cf, hash:/etc/postfix/mailman
</snip>
Note that mailbox_transport is commented out. The virtual_mailbox_domains
allows me to keep the domains that I handle mail for in the db as well.
Then in mysql-virtual.cf I have:
<snip>
hosts = localhost
user = <db_user>
password = <db_password>
dbname = <db_name>
table = virtual
select_field = dest
where_field = alias
additional_conditions = and status = '1'
</snip>
and in mysql-aliases.cf the info is the same except the table is aliases.
In mysql-local_domains.cf I have:
<snip>
hosts = localhost
user = <db_user>
password = <db_password>
dbname = <db_name>
table = domain
select_field = transport
where_field = domain_name
additional_conditions = and transport = '<mail.mydomain.com>'
</snip>
In 'virtual' I store the maps for local users (local meaning cyrus handles
their virtual mailbox locally, not local to Postfix) and in 'aliases' I
store the aliases you are talking about where jo...@example1.com is
forwarded to joe...@example2.com. It works very well and there is a lot
of flexibility for handling mail.
Hope that helps,
Thanks!
We've been in the "going to move to mysql when we can" mode for awhile, and this seems to be the impetus we need to do that. There's quite a bit here to digest, but I sure appreciate your help.
No problem, glad to help. Let me know if you have more questions.