Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm migrating email from old Plesk installations to custom built Ubuntu server running iRedMail (postfix/amavisd/dovecot/etc).

I'm using postfixadmin to administrate all domains and a mysql backend. I've noticed that if I want to "alias" something or create a forward, I can not use an existing mailbox - so I can't copy over the Plesk-style "redirect with saved copy" feature.

I'm currently setting remote aliases via a database and using:

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

If there is a way to still use my database it would be ideal - even if I have to add some columns, and change the query.

Thanks!

share|improve this question

3 Answers 3

up vote 3 down vote accepted

I figured this out. Basically I need to modify the mysql table that saves the aliases so that it supports multiple aliases per address, making it possible to have delivery setup for both the local domain and a remote email.

This works so far, though I've heard that some people attempting this have gotten duplicate emails to the forwarded email account. So far, I have not experienced this.

I was using postfixadmin to manage the accounts, but it doesn't support this usage, so I've had to modify the source code, so that it both displays, edits and deletes aliases properly.

The main lesson here is that when using mysql a single key can be mapped to multiple results, by setting a new primary key i.e. "id" but keeping your postfix query logic the same. The multiple results returned are the same as multiple results in the default dbm/bd files, except that you must create a new record with the same key rather than a single key with some kind of delimited result.

HTH others!

This should work with any maps in mysql.

share|improve this answer
    
In other words, if this SQL query returns multiple values, all is kosher, store and forward works: query = SELECT destination FROM virtual_aliases WHERE source='%s' –  Greg Nov 2 at 3:37

It's probably more kosher to dispatch from postfix' main.cf:

Say, in main.cf:

### let's archive some incoming/outgoing mail:
recipient_bcc_maps = hash:/etc/postfix/recipient-bcc
sender_bcc_maps    = hash:/etc/postfix/sender-bcc

and in the relevant files (recipient-bcc and sender-bcc) for example:

@sender.domain a.local@address

Don't forget to (re)build the databases after editing the files:

postmap hash:recipient-bcc
postmap hash:sender-bcc
share|improve this answer
    
So, I'm using mysql at the moment, so ideally I'd need to create something in the database - any ideas how to do this? –  FilmJ Sep 9 '09 at 5:25

Do you have local accounts for all users?

I've used a .forward file with something like:

user@new-mail-server.example.com, \user

which forwards a copy and keeps a copy in the local spool as well.

share|improve this answer
    
I'm using mysql, and the domains do not have local accounts, only virtual mailboxes. Is there another way to do this using my database, ideally making use of: virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf –  FilmJ Sep 9 '09 at 5:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.