On 9/19/23 15:51, Michael Grant via dovecot wrote:
I've been using dovecot using system usernames (my unix uname as my IMAP username). But today I tried New Outlook which requires the imap username match my email address.
Is there some way to tell dovecot that username@host is the same as uname? (where username@host is an email address and uname is a unix login which might be completely different).
Heya mgrant, been a long time!
If you're using a database for authentication, you can do this sort of translation past using stored functions in MySQL. Queries look something like this:
password_query = SELECT userid AS username, domain, password FROM mail_users WHERE userid = addr_to_uname('%u') AND domain = addr_to_domain_or_default('%u', 'domain.com')
One of the functions is something like this:
DELIMITER ? CREATE FUNCTION addr_to_domain_or_default (userid VARCHAR(255), default_domain VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC BEGIN DECLARE at_pos INT; DECLARE addr_out VARCHAR(255);
SELECT LOCATE('@', userid) INTO at_pos; IF at_pos = 0 THEN CASE userid WHEN 'user1' THEN SET addr_out = 'domain1.com'; WHEN 'user2' THEN SET addr_out = 'domain2.com'; ELSE SET addr_out = default_domain; END CASE; ELSE SELECT SUBSTRING(userid, at_pos + 1) INTO addr_out; END IF;
RETURN addr_out;
END ? DELIMITER ;
This isn't exactly the functionality you want, but it illustrates the kinds of translations that can easy be done on the database side. I've been using a scheme like this for many years with great results.
-Dave
-- Dave McGuire, AK4HZ New Kensington, PA