4

I have a server running Postfix/Dovecot with a MySQL back-end which is configured to use the domain name 'olddomain.com'. I am migrating everything to use another domain 'newdomain.com' and Postfix/Dovecot/Postfixadmin all need to be migrated too. However I need to support both domain names for a while and this should be transparent for users. Emails that are send to '[email protected]' need to arrive at '[email protected]', users need to be able to log in (Postfixadmin/Dovecot) with '[email protected]' and '[email protected]', etc.

I cannot figure out how to do this to support the named use cases, so any help would be appreciated.

Relevant config stuff:

postconf -n

 command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 dovecot_destination_recipient_limit = 1 html_directory = no mail_owner = postfix mail_spool_directory = /var/spool/mail mailq_path = /usr/bin/mailq manpage_directory = /usr/share/man mynetworks_style = host newaliases_path = /usr/bin/newaliases queue_directory = /var/spool/postfix readme_directory = no relay_domains = mysql:/etc/postfix/mysql_relay_domain_maps.cf relayhost = ******* sample_directory = /etc/postfix sendmail_path = /usr/sbin/sendmail setgid_group = postdrop smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_path = private/auth smtpd_sasl_type = dovecot unknown_local_recipient_reject_code = 550 virtual_alias_maps = mysql:/etc/postfix/sql_virtual_alias_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/sql_virtual_domain_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/sql_virtual_mailbox_maps.cf virtual_transport = dovecot 

sql_virtual_mailbox_maps.cf:

 password = **** hosts = localhost dbname = pf_adm query = SELECT CONCAT(maildir, 'Maildir/') AS maildir FROM mailbox WHERE username='%s' AND active = '1' 

sql_virtual_domain_maps.cf:

 user = **** password = **** hosts = localhost dbname = pf_adm query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' 

sql_virtual_alias_maps.cf:

 user = **** password = **** hosts = localhost dbname = pf_adm query = SELECT goto FROM alias WHERE address='%s' AND active = '1' 

doveconf -n

 # 2.1.9: /etc/dovecot/dovecot.conf # OS: Linux 3.4.5-hardened i686 Gentoo Base System release 2.1 ext4 auth_verbose = yes first_valid_gid = 12 first_valid_uid = 8 last_valid_gid = 12 last_valid_uid = 8 mail_gid = 12 mail_location = maildir:/var/mail/%d/%n/Maildir/:INDEX=/var/mail/%d/%n/indexes mail_uid = 8 namespace inbox { inbox = yes location = mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { args = /etc/dovecot/dovecot-sql.conf.ext driver = sql } postmaster_address = [email protected] protocols = imap service auth { unix_listener /var/spool/postfix/private/auth { group = postfix mode = 0660 user = postfix } unix_listener auth-userdb { group = mail mode = 0600 user = mail } } ssl_cert = 

Bonus info (if needed), users are stored like this:

+------------------------+-------------------------+------------+---------------+ | username | maildir | local_part | domain | +------------------------+-------------------------+------------+---------------+ | [email protected] | olddomain.com/username/ | username | olddomain.com | +------------------------+-------------------------+------------+---------------+
2
  • 1
    I don't know if postfix will explode if you do this, but wouldn't having both the olddomain and newdomain accounts point to the same maildir have the same mail available in both accounts? Commented Nov 13, 2012 at 13:21
  • @DerfK I guess I could make a symlink from ${mail_spool_directory}/olddomain.com to ${mail_spool_directory}/newdomain.com but this would only make the mail available if I duplicate each account with '@newdomain.com' instead of '@olddomain.com'. I rather not recreate each account. Commented Nov 13, 2012 at 13:29

1 Answer 1

3

Persistently requiring the full domain name for every address is biting you in the backside here.

It really isn't necessary since all you have is the one domain, so a simple solution would be to alter the SQL lookups to act on the localpart only.

Add the new domain to virtual_mailbox_domains and perform only a localpart lookup on virtual_mailbox_maps.

Both domains and all users in it will be accepted and delivered.

Using a complicated query for virtual_mailbox_domains isn't likely to help, either.
Just list the domain(s) in virtual_mailbox-domains:

virtual_mailbox_domains = olddomain, newdomain 
5
  • So how should a query for a user look? I'm guessing SELECT CONCAT(maildir, 'Maildir/') AS maildir FROM mailbox WHERE local_part='%s' AND active = '1' but this won't work when a user logs in with an email address, right? I also don't get what you mean with 'using the same query'. Commented Nov 13, 2012 at 13:13
  • I have no idea what "log in" means to you; postfix does not log users in. Commented Nov 13, 2012 at 13:36
  • I should have noted I am using Postfixadmin and Dovecot too. Commented Nov 13, 2012 at 14:05
  • Those are unrelated to the postfix MTA. If you need help with them, provide adequate information: the full output of postconf -n, doveconf -n, and relevant log messages that show what is going wrong. Commented Nov 13, 2012 at 14:06
  • I have modified the question accordingly, if more info is needed I am happy to supply it. Commented Nov 13, 2012 at 14:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.