Howto iRedMail with SOGo Mysql authentication on Debian squeeze

1.) First install Debian Squeeze. You can download the Debian netinstall on the officale website

2.) Download and install the last version of iRedMail and choose Mysql backend store mail accounts. For LDAP and SOGo you can find a perfect howto on iRedmail wiki.

3.) Add the Sogo repository and install SOGo.

echo "deb http://www.sogo.nu/files/downloads/SOGo/Debian squeeze squeeze" >> /etc/apt/sources.list
apt-get update
apt-get install sogo memcached rpl zip
# memcached
# this is because of IPv6 errors
rpl '127.0.0.1' localhost /etc/memcached.conf
/etc/init.d/memcached restart

4.) Create the Mysql View for SOGo

 

mysql -u root -p
GRANT ALL PRIVILEGES ON vmail.* TO 'sogo'@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
exit

mysql -u sogo -p
use vmail;
create VIEW sogo_auth (c_uid, c_name, c_password, c_cn, mail, home) AS
select  username, username, password, name, username, maildir from vmail.mailbox;

5.) Configuration for SOGo:

su sogo
defaults write sogod SOGoAuthenticationMethod SQL;
defaults write sogod SOGoUserSources '({canAuthenticate=YES;id=directory;isAddressBook=YES;type=sql;userPasswordAlgorithm=md5;viewURL="mysql://sogo:PASSWORD@localhost:3306/vmail/sogo_auth";})'
defaults write sogod OCSFolderInfoURL "mysql://sogo:PASSWORD@localhost:3306/vmail/sogo_folder_info"
defaults write sogod OCSSessionsFolderURL mysql://sogo:PASSWORD@localhost:3306/vmail/sogo_sessions_folder
defaults write sogod SOGoProfileURL "mysql://sogo:PASSWORD@localhost:3306/vmail/sogo_user_profile"
defaults write sogod OCSEMailAlarmsFolderURL mysql://vmail:PASSWORD@localhost:3306/vmail/sogo_alarms_folder
defaults write sogod SOGoTimeZone "Europe/Berlin"
defaults write sogod SOGoAppointmentSendEMailNotifications YES
defaults write sogod SOGoFoldersSendEMailNotifications YES
defaults write sogod SOGoACLsSendEMailNotifications YES
defaults write sogod SOGoMailingMechanism smtp
defaults write sogod SOGoSMTPServer 127.0.0.1
defaults write sogod SOGoMemcachedHost 127.0.0.1
defaults write sogod SOGoDraftsFolderName Drafts
defaults write sogod SOGoSentFolderName Sent
defaults write sogod SOGoTrashFolderName Trash
defaults write sogod SOGoIMAPServer localhost
defaults write sogod SOGoPasswordChangeEnabled YES
defaults write sogod SOGoSieveScriptsEnabled YES
defaults write sogod SOGoSieveServer sieve://127.0.0.1:4190
defaults write sogod WOPort 127.0.0.1:20000
defaults write sogod SOGoMemcachedHost 127.0.0.1

Change userPasswordAlgorithm in /home/sogo/GNUstep/Defaults/.GNUstepDefaults 

 <key>userPasswordAlgorithm</key>
 <string>md5-crypt</string>

6.) Activate the Apache modules

a2enmod proxy
a2enmod proxy_http
a2enmod rewrite
a2enmod headers

service apache2 restart

7.) Modify the /etc/apache2/conf.d/SOGo.conf file.

RequestHeader set "x-webobjects-server-port" "443"
RequestHeader set "x-webobjects-server-name" "mail.example.com"
RequestHeader set "x-webobjects-server-url" "https://mail.example.com"

8.) Restart Apache2 and SOGo

service apache2 restart
service sogo restart

9.) Login on your server: https://yourserver/SOGo or https://yourserver/mail

Have fun