iredmail-doc/html_bk/dbmail.mysql.centos.html

522 lines
24 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Integrate DBMail with iRedMail (MySQL backend) on CentOS</title>
<link rel="stylesheet" type="text/css" href="./css/markdown.css" />
</head>
<body>
<div id="navigation">
<a href="https://www.iredmail.org" target="_blank">
<img alt="iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>&nbsp;
<span>iRedMail</span>
</a>
&nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="integrate-dbmail-with-iredmail-mysql-backend-on-centos">Integrate DBMail with iRedMail (MySQL backend) on CentOS</h1>
<div class="toc">
<ul>
<li><a href="#integrate-dbmail-with-iredmail-mysql-backend-on-centos">Integrate DBMail with iRedMail (MySQL backend) on CentOS</a><ul>
<li><a href="#changelog">ChangeLog</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#introduce-dbmail">Introduce DBMail</a><ul>
<li><a href="#what-dbmail-is">What DBMail is</a></li>
<li><a href="#why-dbmail">Why DBMail</a></li>
</ul>
</li>
<li><a href="#preparations">Preparations</a></li>
<li><a href="#dbmail-imappop3-server">DBMail, IMAP/POP3 Server</a><ul>
<li><a href="#preparations_1">Preparations</a></li>
<li><a href="#install-dbmail">Install DBMail</a></li>
<li><a href="#configure-dbmail">Configure DBMail</a></li>
<li><a href="#create-testing-account">Create testing account</a></li>
<li><a href="#test-pop3imapmanagesieve-services-with-telnet">Test POP3/IMAP/Managesieve services with telnet</a><ul>
<li><a href="#testing-pop3-service">Testing POP3 service</a></li>
<li><a href="#testing-imap-service">Testing IMAP service</a></li>
<li><a href="#testing-managesieve-service">Testing Managesieve service</a></li>
</ul>
</li>
<li><a href="#integrate-dbmail-in-postfix">Integrate DBMail in Postfix</a></li>
<li><a href="#configure-roundcube-to-work-with-dbmail">Configure Roundcube to work with DBMail</a></li>
</ul>
</li>
<li><a href="#replace-dovecot-with-cyrus-sasl-as-smtp-sasl-auth-daemon">Replace Dovecot with Cyrus-SASL as SMTP SASL auth daemon</a><ul>
<li><a href="#install-cyrus-sasl-libraries">Install Cyrus-SASL libraries</a></li>
<li><a href="#configure-cyrus-sasl">Configure Cyrus-SASL</a></li>
<li><a href="#test-saslauthd-and-troubleshooting">Test saslauthd and troubleshooting</a></li>
<li><a href="#enable-cyrus-sasl-in-postfix">Enable Cyrus-SASL in Postfix</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<h2 id="changelog">ChangeLog</h2>
<ul>
<li>2011-10-26: Cleanup unnecessary process for installing DBMail.</li>
<li>2011-08-27: Initial release.</li>
</ul>
<h2 id="requirements">Requirements</h2>
<p>This tutorial is written for:</p>
<ul>
<li>Red Hat Enterprise Linux 5.x, 6.x</li>
<li>CentOS 5.x, 6.x</li>
<li>Scientific Linux 6.x</li>
</ul>
<h2 id="introduce-dbmail">Introduce DBMail</h2>
<h3 id="what-dbmail-is">What DBMail is</h3>
<p>DBMail is an open-source project that enables storage of mail messages in a relational database. Currently MySQL, PostgreSQL and SQLite can be used as storage backends. Web site: <a href="http://www.dbmail.org/">http://www.dbmail.org/</a>.</p>
<h3 id="why-dbmail">Why DBMail</h3>
<p>Quote from DBMail web site:</p>
<blockquote>
<ul>
<li><strong>Scalability</strong>. DBMail is as scalable as the database system used for storage.</li>
<li><strong>Manageability</strong>. DBMail can be managed by updating the relational database or directory service - without shell access.</li>
<li><strong>Speed</strong>. Dbmail uses very efficient, database specific queries for retrieving mail information.</li>
<li><strong>Security</strong>. Dbmail doesn't require filesystem access. It's as secure as the database and directory server used.</li>
<li><strong>Flexibility</strong>. Changes in a Dbmail system (adding of users, changing passwords etc.) are effective immediately. Users can be stored in the database, or managed separately in an LDAP server such as OpenLDAP or Active Directory.</li>
</ul>
</blockquote>
<p>Notes:</p>
<ul>
<li>For RHEL/CentOS/Scientific Linux 5.x, we will install DBMail-2.2.17 from <a href="http://fedoraproject.org/wiki/EPEL">yum repo <code>EPEL</code></a>.</li>
<li>For RHEL/CentOS/Scientific Linux 6.x, we will install DBMail-3.0.0-rc from <a href="http://fedoraproject.org/wiki/EPEL">yum repo <code>EPEL</code></a>.</li>
<li>DBMail-2.x doesn't provide native TLS/SSL support.</li>
</ul>
<h2 id="preparations">Preparations</h2>
<ul>
<li>
<p>OS:</p>
<ul>
<li>Red Hat Enterprise Linux 5.x or 6.x</li>
<li>CentOS 5.x or 6.x</li>
<li>Scientific Linux 5.x or 6.x</li>
</ul>
</li>
<li>
<p>A running iRedMail server. MySQL server is installed by default in both OpenLDAP and MySQL backends, so either backend is OK. If you don't have a running iRedMail server, please follow our installation guide here: <a href="https://docs.iredmail.org/">https://docs.iredmail.org/</a>.</p>
</li>
<li>
<p>DBMail version:</p>
<ul>
<li>3.0.0 serial: 3.0.0-rc2 or later versions. There's a compatibility issue in DBMail-3.0.0-rc1, it won't work with Cyrus-SASL for SMTP AUTH.</li>
<li>2.2.x.</li>
</ul>
</li>
</ul>
<h2 id="dbmail-imappop3-server">DBMail, IMAP/POP3 Server</h2>
<h3 id="preparations_1">Preparations</h3>
<p>Before installing DBMail software, we need to create necessary system user and
group to run DBMail daemons, and create necessary MySQL database which used to
store mail accounts and messages.</p>
<ul>
<li>Create necessary system user (dbmail) and group (dbmail).</li>
</ul>
<pre><code># useradd -s /sbin/nologin -m dbmail
</code></pre>
<p>Above command will create group <code>dbmail</code> and system user <code>dbmail</code>. You can verify it with command <code>id</code>:</p>
<pre><code># id dbmail
uid=504(dbmail) gid=504(dbmail) groups=504(dbmail)
</code></pre>
<ul>
<li>Create MySQL database <code>dbmail</code> to store mail accounts and mail messages. Replace <code>password_of_dbmail</code> below with your password.</li>
</ul>
<pre><code class="language-sql">$ mysql -uroot -p
mysql&gt; CREATE DATABASE dbmail DEFAULT CHARACTER SET utf8;
mysql&gt; GRANT ALL ON dbmail.* TO dbmail@localhost IDENTIFIED BY 'password_of_dbmail';
mysql&gt; FLUSH PRIVILEGES;
</code></pre>
<p>We now have a MySQL database <code>dbmail</code>, you can access it with MySQL user <code>dbmail</code> and password <code>password_of_dbmail</code>. You can verify it with MySQL command line:</p>
<pre><code class="language-sql">$ mysql -udbmail -p
Enter password: # &lt;- Type password of MySQL user dbmail here.
mysql&gt; show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dbmail | # &lt;- Database 'dbmail' is available.
+--------------------+
2 rows in set (0.04 sec)
</code></pre>
<ul>
<li>Stop Dovecot daemon. Since Dovecot will be replaced by DBMail, we must stop it:</li>
</ul>
<pre><code># /etc/init.d/dovecot stop
# chkconfig --level 345 dovecot off
</code></pre>
<h3 id="install-dbmail">Install DBMail</h3>
<p>DBMail is available in <a href="http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F">EPEL repository</a>, we will use this yum repository to install DBMail.</p>
<p>It's now ready to install DBMail core component and library used to connect MySQL.</p>
<pre><code>#
# ---- For RHEL/CentOS/Scientific Linux 5.x ----
#
# rpm -ivh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# yum clean all
# yum install dbmail dbmail-mysql
#
# ---- For RHEL/CentOS/Scientific Linux 6.x ----
#
# rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
# yum clean all
# yum install dbmail
</code></pre>
<p>On RHEL/CentOS/Scientific Linux 6.x, please make sure you have DBMail 3.0.0-rc3 or later version installed:</p>
<pre><code># rpm -q dbmail
dbmail-3.0.0-0.6.rc3.el6.x86_64
</code></pre>
<p>Main configure file of DBMail is <code>/etc/dbmail.conf</code> by default, we will configure it later.</p>
<p>DBMail provides a MySQL template file <code>/usr/share/doc/dbmail-x.y.z/sql/mysql/create_tables.mysql</code> (replace 'x.y.z' by real version number on your server), we should import it to create necessary MySQL tables to store mail accounts and messages. Here we use 'dbmail-3.0.0' for example.</p>
<pre><code class="language-shell"># rpm -ql dbmail | grep 'create_tables.mysql'
/usr/share/doc/dbmail-3.0.0/sql/mysql/create_tables.mysql
# mysql -udbmail -p
mysql&gt; USE dbmail;
mysql&gt; SOURCE /usr/share/doc/dbmail-3.0.0/sql/mysql/create_tables.mysql;
mysql&gt; SHOW TABLES; # &lt; See what tables were created.
</code></pre>
<h3 id="configure-dbmail">Configure DBMail</h3>
<p>Now open configure file of DBMail, <code>/etc/dbmail.conf</code>, update below settings:</p>
<pre><code>[DBMAIL]
# Store mail messages in which kind of database. We use MySQL here.
driver = mysql
# Authenticate mail users from SQL database or LDAP server. We use SQL (MySQL) here.
authdriver = sql
# Host for database.
host = 127.0.0.1
sqlport = 3306
sqlsocket = /var/lib/mysql/mysql.sock
# Database username.
user = dbmail
# Database password.
pass = password_of_dbmail
# Database name.
db = dbmail
# Table prefix. Defaults to &quot;dbmail_&quot; if not specified.
table_prefix = dbmail_
# ---- For DBMail-2.2.x ----
# Debug level. 0 for production use, 511 for debug.
#TRACE_SYSLOG = 32
#TRACE_STDERR = 32
# ---- For DBMail-3.0.0 ----
file_logging_levels = 32
syslog_logging_levels = 32
# ---- For DBMail-2.2.x ----
# Run DBMail services as which system user and group.
#EFFECTIVE_USER = dbmail
#EFFECTIVE_GROUP = dbmail
# ---- For DBMail-3.0.0 ----
effective_user = dbmail
effective_group = dbmail
# directory for storing PID files.
pid_directory = /var/run/dbmail
# Where we have DBMail libraries installed.
# It's /usr/lib/dbmail on i386 system, /usr/lib64/dbmail on x86_64 system.
library_directory = /usr/lib64/dbmail
###########################################
# Below settings are DBMail-3.0.0 special #
###########################################
#
# SSL/TLS certificates
#
# A file containing a list of CAs in PEM format
tls_cafile = /etc/pki/tls/certs/iRedMail_CA.pem
# A file containing a PEM format certificate
tls_cert = /etc/pki/tls/certs/iRedMail_CA.pem
# A file containing a PEM format RSA or DSA key
tls_key = /etc/pki/tls/private/iRedMail.key
hash_algorithm = SHA1
[POP]
tls_port = 995
[IMAP]
tls_port = 993
[SIEVE]
# Note: Please set it to 2000 on RHEL/CentOS 5.x, 4190 on RHEL/CentOS 6.x.
port = 4190
</code></pre>
<p>Create directory to store PID files:</p>
<pre><code># mkdir /var/run/dbmail
# chown dbmail:dbmail /var/run/dbmail
</code></pre>
<p>It's ready to start DBMail daemons:</p>
<pre><code># for i in dbmail-imapd dbmail-lmtpd dbmail-pop3d dbmail-timsieved; do /etc/init.d/$i restart; done
</code></pre>
<p>Make sure DBMail daemons will start when system startup:</p>
<pre><code># for i in dbmail-imapd dbmail-lmtpd dbmail-pop3d dbmail-timsieved; do chkconfig --level 345 $i on; done
</code></pre>
<p>Check status of DBMail daemons:</p>
<pre><code># netstat -ntlp | grep dbmail
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 1747/dbmail-pop3d
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 1710/dbmail-imapd
tcp 0 0 0.0.0.0:24 0.0.0.0:* LISTEN 1734/dbmail-lmtpd
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 1760/dbmail-timsiev
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 1710/dbmail-imapd
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 1747/dbmail-pop3d
</code></pre>
<h3 id="create-testing-account">Create testing account</h3>
<p>DBMail daemons are running, let's create a testing account to test POP3/POP3S/IMAP/IMAPS/Managesieve services.</p>
<ul>
<li>Create a testing account <code>test@domain.ltd</code>, with password <code>mypass</code>:</li>
</ul>
<pre><code># dbmail-users -p md5 -a test@domain.ltd -w mypass -s test@domain.ltd
Adding INBOX for new user... ok.
[test@domain.ltd]
Done
test@domain.ltd:x:5:0:0.00:0.00:test@domain.ltd
</code></pre>
<p>Refer to DBMail wiki site for more information about managing users: http://dbmail.org/dokuwiki/doku.php/manage_users</p>
<h3 id="test-pop3imapmanagesieve-services-with-telnet">Test POP3/IMAP/Managesieve services with telnet</h3>
<p>It's OK to test POP3/POP3S/IMAP/IMAPS services with telnet, mutt or Roundcube webmail, here we use telnet and mutt instead. After testing, you can login to Roundcube Webmail directly.</p>
<h4 id="testing-pop3-service">Testing POP3 service</h4>
<pre><code>$ telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK DBMAIL pop3 server ready to rock &lt;e2ef9332465296ebd4ec7ae5828d9cc3@c60.iredmail.org&gt; # &lt;-- DBMail response
USER test@domain.ltd # &lt;- Type this command to login
+OK Password required for test@domain.ltd
PASS mypass # &lt;-- Type your password
+OK test@domain.ltd has 0 messages (0 octets)
LIST # &lt;-- Check mailbox.
+OK 0 messages (0 octets)
.
QUIT # &lt;-- DIsconnect
+OK see ya later
Connection closed by foreign host.
</code></pre>
<p>Telnet doesn't support SSL service, so we test POP3S with <code>mutt</code> (a console based mail client application) instead.</p>
<pre><code>$ mutt -f pops://&quot;test@domain.ltd&quot;:mypass@localhost
</code></pre>
<p>If POP3S works well, mutt will show you an empty mailbox. Then type 'q' to exit mutt.</p>
<h4 id="testing-imap-service">Testing IMAP service</h4>
<pre><code>$ telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 AUTH=LOGIN AUTH=CRAM-MD5 STARTTLS ID] dbmail 3.0.0-rc1 ready. # &lt;-- DBMail response.
. LOGIN test@domain.ltd mypass # &lt;-- Login. Don't forget the leading dot in command.
* CAPABILITY IMAP4rev1 STARTTLS ID ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE
. OK LOGIN completed
. LIST '' '*' # &lt;-- Check mailbox.
* LIST (\hasnochildren) &quot;/&quot; &quot;INBOX&quot;
. OK LIST completed
. LOGOUT # &lt;-- Disconnect.
* BYE
. OK LOGOUT completed
Connection closed by foreign host.
</code></pre>
<p>Telnet doesn't support SSL service, so we test IMAPS with <code>mutt</code> instead.</p>
<pre><code>$ mutt -f imaps://&quot;test@domain.ltd&quot;:mypass@localhost
</code></pre>
<p>If IMAPS works well, mutt will show you an empty mailbox. Then type 'q' to exit mutt.</p>
<h4 id="testing-managesieve-service">Testing Managesieve service</h4>
<p>Before testing managesieve service, we have to encode username and password first.</p>
<ul>
<li>Download a small perl script here: http://www.rename-it.nl/dovecot/utilities/sieve-auth-command.pl</li>
<li>Run this script to encode your username and password:</li>
</ul>
<pre><code>$ perl sieve-auth-command.pl test@domain.ltd mypass
AUTHENTICATE &quot;PLAIN&quot; &quot;AHRlc3RAZG9tYWluLmx0ZABteXBhc3M=&quot;
</code></pre>
<p>The command output is what we need.</p>
<p>Now start to test managesieve service:</p>
<pre><code>$ telnet localhost 4190
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
&quot;IMPLEMENTATION&quot; &quot;DBMail timsieved 3.0.0-rc1&quot;
&quot;SASL&quot; &quot;PLAIN&quot;
&quot;SIEVE&quot; &quot;regex imap4flags relational subaddress fileinto reject envelope vacation notify &quot;
OK
AUTHENTICATE &quot;PLAIN&quot; &quot;AHRlc3RAZG9tYWluLmx0ZABteXBhc3M=&quot; # &lt;-- Type this command.
OK
^] # &lt;-- Press Ctrl + ] to exit telnet session.
telnet&gt; quit # &lt;-- Type 'quit' to quit telnet program.
Connection closed.
</code></pre>
<h3 id="integrate-dbmail-in-postfix">Integrate DBMail in Postfix</h3>
<p>Backup Postfix config files before we go further:</p>
<pre><code># cp /etc/postfix/main.cf /etc/postfix/main.cf.bak
# cp /etc/postfix/master.cf /etc/postfix/master.cf.bak
</code></pre>
<ul>
<li>Add below line in <code>/etc/postfix/master.cf</code>, it's new transport provided by DBMail.</li>
</ul>
<pre><code>dbmail-lmtp unix - - n - - lmtp
</code></pre>
<ul>
<li>Since DBMail uses different SQL structure from iRedMail, we have to disable some iRedMail special features in Postfix first.</li>
</ul>
<pre><code># postconf -e recipient_bcc_maps='' relay_domains='$mydestination' sender_bcc_maps='' transport_maps='' virtual_alias_maps=''
</code></pre>
<ul>
<li>Update postfix setting to use DBMail transport:</li>
</ul>
<pre><code># postconf -e virtual_transport='dbmail-lmtp:127.0.0.1:24'
</code></pre>
<ul>
<li>
<p>Update postfix setting in <code>/etc/postfix/main.cf</code>, remove <code>reject_unknown_sender_domain</code> in <code>smtpd_recipient_restrictions</code> setting.</p>
</li>
<li>
<p>Update postfix setting to lookup mail users and aliases from DBMail MySQL database:</p>
</li>
</ul>
<pre><code># postconf -e smtpd_sender_login_maps='proxy:mysql:/etc/postfix/dbmail_recipients.cf'
# postconf -e virtual_mailbox_domains='proxy:mysql:/etc/postfix/dbmail_domains.cf'
# postconf -e virtual_mailbox_maps='proxy:mysql:/etc/postfix/dbmail_mailboxes.cf'
</code></pre>
<p>Content of file <code>/etc/postfix/dbmail_recipients.cf</code>:</p>
<pre><code>hosts = 127.0.0.1
dbname = dbmail
user = dbmail
password = password_of_dbmail
query = SELECT alias FROM dbmail_aliases WHERE alias='%s' LIMIT 1
</code></pre>
<p>Content of file <code>/etc/postfix/dbmail_domains.cf</code>:</p>
<pre><code>hosts = 127.0.0.1
dbname = dbmail
user = dbmail
password = password_of_dbmail
query = SELECT DISTINCT 1 FROM dbmail_aliases WHERE SUBSTRING_INDEX(alias, '@', -1) = '%s'
</code></pre>
<p>Content of file <code>/etc/postfix/dbmail_mailboxes.cf</code>:</p>
<pre><code>hosts = 127.0.0.1
dbname = dbmail
user = dbmail
password = password_of_dbmail
query = SELECT 1 FROM dbmail_aliases WHERE alias='%s' LIMIT 1
</code></pre>
<ul>
<li>Test MySQL queries:</li>
</ul>
<pre><code># postmap -q 'test@domain.ltd' mysql:/etc/postfix/dbmail_recipients.cf
test@domain.ltd
# postmap -q 'domain.ltd' mysql:/etc/postfix/dbmail_domains.cf
1
# postmap -q 'test@domain.ltd' mysql:/etc/postfix/dbmail_mailboxes.cf
1
</code></pre>
<ul>
<li>It's now OK to send a test email with command <code>mail</code> (provided by package <code>mailx</code>) after restarting Postfix service:</li>
</ul>
<pre><code># /etc/init.d/postfix restart
# mail -s &quot;test&quot; test@domain.ltd &lt; /etc/hosts
</code></pre>
<p>Log in Postfix log file /var/log/maillog:</p>
<blockquote>
<p>Aug 14 06:40:20 c60 postfix/pickup[6017]: B89A141FAD: uid=0 from=<root>
Aug 14 06:40:20 c60 postfix/cleanup[6022]: B89A141FAD: message-id=<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#50;&#48;&#49;&#49;&#48;&#56;&#49;&#52;&#49;&#48;&#52;&#48;&#50;&#48;&#46;&#66;&#56;&#57;&#65;&#49;&#52;&#49;&#70;&#65;&#68;&#64;&#99;&#54;&#48;&#46;&#105;&#114;&#101;&#100;&#109;&#97;&#105;&#108;&#46;&#111;&#114;&#103;">&#50;&#48;&#49;&#49;&#48;&#56;&#49;&#52;&#49;&#48;&#52;&#48;&#50;&#48;&#46;&#66;&#56;&#57;&#65;&#49;&#52;&#49;&#70;&#65;&#68;&#64;&#99;&#54;&#48;&#46;&#105;&#114;&#101;&#100;&#109;&#97;&#105;&#108;&#46;&#111;&#114;&#103;</a>
Aug 14 06:40:20 c60 postfix/qmgr[6016]: B89A141FAD: from=<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#99;&#54;&#48;&#46;&#105;&#114;&#101;&#100;&#109;&#97;&#105;&#108;&#46;&#111;&#114;&#103;">&#114;&#111;&#111;&#116;&#64;&#99;&#54;&#48;&#46;&#105;&#114;&#101;&#100;&#109;&#97;&#105;&#108;&#46;&#111;&#114;&#103;</a>, size=566, nrcpt=1 (queue active)
Aug 14 06:40:20 c60 postfix/lmtp[6025]: B89A141FAD: to=<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#101;&#115;&#116;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#108;&#116;&#100;">&#116;&#101;&#115;&#116;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#108;&#116;&#100;</a>, relay=127.0.0.1[127.0.0.1]:24, delay=0.15, delays=0.05/0.02/0/0.09, dsn=2.0.0, status=sent (215 Recipient <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#101;&#115;&#116;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#108;&#116;&#100;">&#116;&#101;&#115;&#116;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#108;&#116;&#100;</a> OK)
Aug 14 06:40:20 c60 postfix/qmgr[6016]: B89A141FAD: removed</p>
</blockquote>
<h3 id="configure-roundcube-to-work-with-dbmail">Configure Roundcube to work with DBMail</h3>
<p>Change below setting in <code>/var/www/roundcubemail/config/main.inc.php</code>:</p>
<pre><code class="language-php">$rcmail_config['imap_auth_type'] = &quot;LOGIN&quot;;
</code></pre>
<p>Restart Apache, you can now view sent email after logging into Roundcube webmail:</p>
<pre><code># /etc/init.d/httpd restart
</code></pre>
<h2 id="replace-dovecot-with-cyrus-sasl-as-smtp-sasl-auth-daemon">Replace Dovecot with Cyrus-SASL as SMTP SASL auth daemon</h2>
<p>Postfix uses <code>dovecot</code> as SASL type in iRedMail by default, since Dovecot will be replaced by DBMail, we cannot use Dovecot anymore. So we're going to install Cyrus-SASL libraries, and use daemon 'saslauthd' for SMTP SASL auth.</p>
<p>In this section, we will:</p>
<ul>
<li>Install Cyrus-SASL libraries.</li>
<li>Configure Cyrus-SASL.</li>
<li>Running and testing Cyrus-SASL auth daemon 'saslauthd' immediately.</li>
</ul>
<h3 id="install-cyrus-sasl-libraries">Install Cyrus-SASL libraries</h3>
<p>Cyrus-SASL libraries are available in default yum repositories.
* For RHEL, they're available in yum repository <code>rhn</code> or CD/DVD images.
* For CentOS and Scientific Linux, they're available in default yum repositories.</p>
<pre><code># yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-sql cyrus-sasl-plain cyrus-sasl-md5
</code></pre>
<h3 id="configure-cyrus-sasl">Configure Cyrus-SASL</h3>
<p>Configure Cyrus-SASL daemon config file:</p>
<ul>
<li>
<p>On RHEL/CentOS/Scientific Linux 5.x:</p>
<ul>
<li>On i386, it's /usr/lib/sasl2/smtpd.conf</li>
<li>On x86_64, it's /usr/lib64/sasl2/smtpd.conf</li>
</ul>
</li>
<li>
<p>On RHEL/CentOS/Scientific Linux 6.x, it's <code>/etc/sasl2/smtpd.conf</code>.</p>
</li>
</ul>
<pre><code>pwcheck_method: saslauthd
mech_list: plain login
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: dbmail
sql_passwd: password_of_dbmail
sql_database: dbmail
sql_verbose: no
sql_select: SELECT passwd FROM dbmail_users WHERE userid = '%u'
</code></pre>
<p>Update <code>/etc/sysconfig/saslauthd</code> (refer to manual page saslauthd(8) for more information):</p>
<pre><code>SOCKETDIR=/var/spool/postfix/var/run/saslauthd
MECH=rimap
FLAGS='-O 127.0.0.1 -r'
</code></pre>
<p>Notes:</p>
<ul>
<li>We set <code>SOCKETDIR</code> to <code>/var/spool/postfix/var/run/saslauthd/</code> so that Postfix works fine under chroot.</li>
<li>Dont forget <code>-r</code> in <code>FLAGS</code>. It will force saslauthd daemon uses full email address as user name.</li>
</ul>
<p>Create directory used to store saslauthd daemon socket file:</p>
<pre><code># mkdir -p /var/spool/postfix/var/run/saslauthd/
</code></pre>
<p>Start service saslauthd now, and make it auto start when system boot:</p>
<pre><code># /etc/init.d/saslauthd restart
# chkconfig --level 345 saslauthd on
</code></pre>
<h3 id="test-saslauthd-and-troubleshooting">Test saslauthd and troubleshooting</h3>
<pre><code># testsaslauthd -f /var/spool/postfix/var/run/saslauthd/mux -u 'test@domain.ltd' -p 'mypass'
0: OK &quot;Success.&quot;
</code></pre>
<p>Note: If you're running DBMail-3.0.0-rc1, you will always get <code>0: NO "authentication failed"</code>, because DBMail-3.0.0-rc1 has a compatibility issue with Cyrus-SASL.</p>
<h3 id="enable-cyrus-sasl-in-postfix">Enable Cyrus-SASL in Postfix</h3>
<pre><code># postconf -e smtpd_sasl_path='smtpd' smtpd_sasl_type='cyrus'
</code></pre>
<p>Restarting Postfix service to make it work:</p>
<pre><code># /etc/init.d/postfix restart
</code></pre>
<p>You can now send email with Roundcube webmail.</p><div class="footer">
<p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div></body></html>