Skip to content

Instantly share code, notes, and snippets.

@cb1kenobi
Created July 17, 2011 19:20
Show Gist options
  • Save cb1kenobi/1087957 to your computer and use it in GitHub Desktop.
Save cb1kenobi/1087957 to your computer and use it in GitHub Desktop.
A better /etc/postfix/mysql-virtual_mailboxes.cf with + in email address support
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users u JOIN (SELECT '%s' AS orig_email) x ON u.email = CASE WHEN LOCATE('+', x.orig_email) > 0 AND LOCATE('+', x.orig_email) < LOCATE('@', x.orig_email) THEN CONCAT(SUBSTRING_INDEX(x.orig_email, '+', 1), '@', SUBSTRING_INDEX(x.orig_email, '@', -1)) ELSE x.orig_email END
hosts = 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment