[Dovecot] Setting a Default Domain

Ben Winslow rain at bluecherry.net
Tue Mar 28 21:34:20 EEST 2006


On Monday 27 March 2006 21:47, Richard Laager wrote:
> I'm working on migrating to Dovecot. At the moment, I have a mail
> path that includes the domain, so I'm using %d to get that.
> However, if users authenticate without specifying a domain (i.e.
> using "bob" instead of "bob at wiktel.com"), then %d expands to
> nothing. I'd like to have that expand to a default domain
> (wiktel.com) instead. Is that possible?
>
> Thanks,
> Richard

The best solution to this (afaik) is to let the SQL server to the 
dirty work for you, e.g.:
SELECT [...] CASE WHEN ('%d' = '') THEN 'default.com' ELSE '%d' END AS 
domain [...]

Depending on your database schema, you may be able to get away without 
the CASE statement usage with something like this:
SELECT ... WHERE (('%d' != '' AND domain='%d') OR ('%d' = '' AND 
domain='default.com') ...

It's not the greatest of solutions, but it works well enough.

HTH,
-- 
Ben Winslow <rain at bluecherry.net>


More information about the dovecot mailing list