[tpop3d-discuss]auth_mysql column with username@domain.tld

Jim Flowers jflowers at ezo.net
Sat, 8 Oct 2005 00:31:23 -0400


I have been able to set up my tpop3d server to access virtual email boxes from
a mysql database derived from other mail programs.  In order to do this, I use
the following template:

listen-address: ###.###.###.###:110(domain.tld)
...
append-domain: true
...
auth-mysql-pass-query: SELECT CONCAT('/usr/local/virtual/', mailbox.maildir),
        CONCAT('{crypt_md5}', mailbox.password), 'www', 'bsd'
        FROM mailbox, domain WHERE mailbox.username = '$(user)'      
        AND mailbox.domain = domain.domain;

to accommodate different tables, columns and data formats.

In particular, the < FROM mailbox, domain WHERE mailbox.username = '$(user)' >
clause is required because in the mailbox table, the username column data
format is 'username@domain.tld'.

So far so good.  As long as the client provides 'username@domain.tld'
everything works as expected.

Now I want it to work when the client just enters 'username', with the domain
identified by the server address.  The internal variable $(domain) is
correctly set to 'domain.tld' via the listen definition but the $(user)
internal variable remains 'username' and the mysql lookup fails.  As
configured, append-domain does not have the desired affect.

Apparently, I need a different variable or to be able to concatenate
'$(username)@$(domain)' in order to perform the mysql lookup.

Can this be done with the template in apop3d.conf?  

If not, I suppose the only solution will be to use mysql string functions in
the SELECT statement to obtain separate values for the local_part and
domain_name columns to allow the append-domain routine to solve the problem.

Thanks for any suggestions.

--
Jim Flowers<jflowers@ezo.net>