Question:
I am migrating from a legacy mail-server where users login via POP3/IMAP as user%domain.comI need to support this authentication mode, so I can migrate to @Mail without having end users change their mail-client username to login. How do I support this?
Answer:
This is possible to achieve by altering the SQL query used to authenticate users in @Mail.To enable visit the Webadmin > Services > POP3/IMAP
Set a default domain for authentication, and select the SQL-query type = "Fast"
Next the /usr/local/atmail/mailserver/etc/authmysqlrc controls how the POP3/IMAP server handles authentication for end users.
Change the entry MYSQL_SELECT_CLAUSE to read:
MYSQL_SELECT_CLAUSE SELECT distinct UserSession.Account, '', UserSession.Password, '3000','3000',Users.MailDir, Users.MailDir, '', 'allowimap=1,allowpop3=1' FROM UserSession, Users WHERE (UserSession.Account = CONCAT('$(local_part)', '@', '$(domain)') OR UserSession.Account = REPLACE('$(local_part)', '%', '@') ) AND UserSession.Account = Users.Account and (Users.Account=CONCAT('$(local_part)', '@', '$(domain)') or Users.Account=REPLACE('$(local_part)', '%', '@') ) and (Users.UserStatus != '1' or Users.UserStatus is null)
This will supporting logging in as user@domain or user%domain
To test the changes restart services:
/etc/init.d/atmailserver restart
-
In order to support the Webadmin scripts updating the authmysqlrc you need to edit the source
/usr/local/atmail/webmail/libs/Atmail/Exim_Config.php
Locate the following code and replace the code in bold:
if($pref['pop3imap_querytype'] == "quick") {
$courier_conf['MYSQLQUERY'] =
# The SQL query used by @Mail to authentication with the mySQL database
# Note the UID 3000 is used for the query, which is the atmail username that has permissions
# over the /usr/local/atmail/users directory
#Short query - No group support to toggle POP3/IMAP on/off on a group basis
MYSQL_SELECT_CLAUSE SELECT distinct UserSession.Account, $crypt, UserSession.Password, '3000','3000',Users.MailDir, Users.MailDir, '', 'allowimap=1,allowpop3=1' FROM UserSession, Users WHERE (UserSession.Account = CONCAT('$(local_part)', '@', '$(domain)') OR UserSession.Account = REPLACE('$(local_part)', '%', '@') ) AND UserSession.Account = Users.Account and (Users.Account=CONCAT('$(local_part)', '@', '$(domain)') or Users.Account=REPLACE('$(local_part)', '%', '@') ) and (Users.UserStatus != '1' or Users.UserStatus is null)
-
Once modified you now have a system that can authenticate with user%domain.com or user@domain