While preparing this email for the mailing list I found the solution to my problem. But I thought I'd still send it in case it may help someone else.

tl;dr:
Use expansion format modifiers to normalize mail directories.

Problem:
Here's what I have under my virtual mail directory:

# cd /var/spool/vmail/
# ls -1
ECENTRYX.COM
TARGETMEISTER.COM
TargetMeister.com
ecentryx.com
targetmeister.com
# ls -1 targetmeister.com/
Clint
clint

Solution:
At first, I thought of symlinking all the different case combinations to the all-lowercase directories. But that's a nasty hack. Then I thought of adding all the different case combinations of email addresses in my users table and map them to the lowercase destination. Again, another nasty hack. So I thought I better check the man page. Sure enough, the fix is easy: *expansion format modifiers*.

So I changed my config from:

accept from any for domain <domains> virtual <users> \
        deliver to maildir "/var/spool/vmail/%{dest.domain}/%{dest.user}"

to:

accept from any for domain <domains> virtual <users> deliver to maildir \
"/var/spool/vmail/%{dest.domain:lowercase}/%{dest.user:lowercase|strip}"

No more directory pollution under my virtual mail tree. Problem solved!

What's crazy is that I had important emails in these "uppercase" directories dating back almost a year. They were from my bank and various vendors. So for the record, major US banks and some old-school businesses like to uppercase email addresses.


For reference, here are all of my config files before the fix:

==========
# cat /etc/mail/mailname
mail.targetmeister.com


==========
# cat /etc/mail/smtpd.conf
table users     "/etc/mail/users"
table passwd    "/etc/mail/passwd"
table aliases   "/etc/mail/aliases"
table domains   "/etc/mail/domains"

pki tm certificate "/etc/ssl/mail.targetmeister.com.crt"
pki tm key "/etc/ssl/private/mail.targetmeister.com.key"

listen on localhost
listen on mail port smtp       tls         pki tm auth-optional <passwd>
listen on mail port submission tls-require pki tm auth <passwd>

accept from local for local alias <aliases> deliver to mbox
accept from any for domain <domains> virtual <users> \
        deliver to maildir "/var/spool/vmail/%{dest.domain}/%{dest.user}"
accept from local for any relay


==========
# cat /etc/mail/domains
ecentryx.com
targetmeister.com


========== [obscured sample]
# cat /etc/mail/users

# The Dovecot IMAP server runs as vmail. It manages access to all mail and is
# the final delivery destination.

### ECENTRYX.COM ###
[email protected]              vmail
[email protected]               [email protected]

### TARGETMEISTER.COM ###
[email protected]         vmail
[email protected]           [email protected]


--
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]

Reply via email to