<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://bliki.rimuhosting.com/rdf'>
    <s:Snip rdf:about='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/postfixadmin+on+debian'
         s:cUser='abdallah'
         s:oUser=''
         s:mUser='abdallah'>
        <s:name>knowledgebase/linux/mail/postfixadmin on debian</s:name>
        <s:content>{link:Postfix Admin|http://sourceforge.net/projects/postfixadmin/} is a web-based GUI for setting up mail users for a Postfix+MySQL setup.&#xD;&#xA;&#xD;&#xA;It will let you create users and aliases per domain.&#xD;&#xA;&#xD;&#xA;This HOWTO goes over install Postfix Admin, Postfix with a MySQL backend and SMTP auth enabled, and Dovecot (for POP3/POP3/IMAP/IMAPS) with a MySQL backend.&#xD;&#xA;&#xD;&#xA;While this HOWTO is was tested on Debian Etch, the Postfix/MySQL setup is generic and should work fine on most distributions.&#xD;&#xA;&#xD;&#xA;If you&apos;re after per-user spam and virus filtering for your virtual users, see the howto here: http://bliki.rimuhosting.com/space/knowledgebase/linux/mail/postfix+with+amavis+and+mysql&#xD;&#xA;&#xD;&#xA;Postfixadmin is now in the official repositories for Debian and Ubuntu. Simply use apt-get to install it:&#xD;&#xA;{code:none}&#xD;&#xA;apt-get install postfixadmin&#xD;&#xA;{code}&#xD;&#xA;NOTE: The package did not make it to the Ubuntu repositories. Simply download the file from http://sourceforge.net/project/showfiles.php?group_id=191583&amp;package_id=225300 and run: &#xD;&#xA;{code:none}&#xD;&#xA;dpkg -i postfixadmin_2.2.0_all.deb&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Postfixadmin will be installed in /usr/share/postfixadmin/&#xD;&#xA;the configuration file will be in /etc/postfixadmin/config.inc.php &#xD;&#xA;and the following alias is added to the apache configuration in the file&#xD;&#xA;/etc/apache2/conf.d/postfixadmin:&#xD;&#xA;{code:none}&#xD;&#xA;Alias /postfixadmin /usr/share/postfixadmin&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;All the above can be done manually if you do decide to install using the source tarball.&#xD;&#xA;&#xD;&#xA;Configure Postfix Admin to match your setup (e.g. to make the database passwords match, set your default domain, etc)&#xD;&#xA;&#xD;&#xA;Edit the file /usr/share/postfixadmin/config.inc.php and set the following:&#xD;&#xA;{code:none}&#xD;&#xA;vi config.inc.php&#xD;&#xA;[...]&#xD;&#xA;$CONF[&apos;configured&apos;] = true;&#xD;&#xA;$CONF[&apos;postfix_admin_url&apos;] = &apos;http://yourdomain.tld/postfixadmin&apos;;&#xD;&#xA;&#xD;&#xA;$CONF[&apos;database_type&apos;] = &apos;mysql&apos;;&#xD;&#xA;$CONF[&apos;database_host&apos;] = &apos;localhost&apos;;&#xD;&#xA;$CONF[&apos;database_user&apos;] = &apos;postfixadmin&apos;;&#xD;&#xA;$CONF[&apos;database_password&apos;] = &apos;SecretPassword!&apos;;&#xD;&#xA;$CONF[&apos;database_name&apos;] = &apos;postfix&apos;;&#xD;&#xA;&#xD;&#xA;$CONF[&apos;domain_path&apos;] = &apos;YES&apos;;&#xD;&#xA;$CONF[&apos;domain_in_mailbox&apos;] = &apos;NO&apos;;&#xD;&#xA;$CONF[&apos;encrypt&apos;] = &apos;cleartext&apos;;&#xD;&#xA;{code}&#xD;&#xA;Take a look at the rest of that file if you need to make more tweaks.&#xD;&#xA;&#xD;&#xA;You can quickly change the default domain to your own:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;replace &quot;change-this-to-your.domain.tld&quot; &quot;yourdomain.com&quot; -- /usr/share/postfixadmin/config.inc.php&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Create the database and user in mysql:&#xD;&#xA;{code:none}&#xD;&#xA;shell&gt; mysql -u root -p&#xD;&#xA;mysql&gt; create database postfix;&#xD;&#xA;mysql&gt; grant all privileges on postfix.* to &apos;postfixadmin&apos;@&apos;localhost&apos; identified by &apos;SecretPassword!&apos;;&#xD;&#xA;mysql&gt; flush privileges;&#xD;&#xA;mysql&gt; \q&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;Then browse to http://yourdomain.com/postfixadmin/ or http://yourip/postfixadmin/. It will prompt you to run Setup. Make sure the Setup Checker says &apos;OK&apos; for everything.&#xD;&#xA;&#xD;&#xA;Remove the setup.php as it recommends.&#xD;&#xA;&#xD;&#xA;Then browse to http://yourdomain.com/postfixadmin/admin. You should get prompted. Login with the admin email you registered earlier in the setup page.&#xD;&#xA;From here you can add domains, mailboxes, etc. But Postfix won&apos;t see these yet. We need to install Postfix, and configure it.&#xD;&#xA;&#xD;&#xA;Install Postfix, SASL2 with MySQL support&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;apt-get install postfix-mysql postfix-tls libsasl2-modules-sql libsasl2-modules&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Add the following to /etc/postfix/main.cf&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf&#xD;&#xA;virtual_gid_maps = static:106&#xD;&#xA;virtual_mailbox_base = /home/vmail&#xD;&#xA;virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf&#xD;&#xA;virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf&#xD;&#xA;virtual_minimum_uid = 106&#xD;&#xA;virtual_transport = virtual&#xD;&#xA;virtual_uid_maps = static:106&#xD;&#xA;&#xD;&#xA;broken_sasl_auth_clients = yes&#xD;&#xA;smtpd_recipient_restrictions =&#xD;&#xA;  permit_mynetworks,&#xD;&#xA;  permit_sasl_authenticated,&#xD;&#xA;  reject_non_fqdn_hostname,&#xD;&#xA;  reject_non_fqdn_sender,&#xD;&#xA;  reject_non_fqdn_recipient,&#xD;&#xA;  reject_unauth_destination,&#xD;&#xA;  reject_unauth_pipelining,&#xD;&#xA;  reject_invalid_hostname&#xD;&#xA;smtpd_sasl_auth_enable = yes&#xD;&#xA;smtpd_sasl_local_domain = $myhostname&#xD;&#xA;smtpd_sasl_security_options = noanonymous&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Note: UID/GID 106 may be different on your system. Check your postfix (or vmail) user in /etc/passwd and set accordingly. For example on my server:&#xD;&#xA;{code:none}&#xD;&#xA;# grep postfix /etc/passwd&#xD;&#xA;postfix:x:102:105::/var/spool/postfix:/bin/false&#xD;&#xA;--&gt; uid: 102; gid: 105&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Create the following files in /etc/postfix/:&#xD;&#xA;&#xD;&#xA;mysql_virtual_alias_maps.cf&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;user = postfix&#xD;&#xA;password = SecretPassword!&#xD;&#xA;hosts = localhost&#xD;&#xA;dbname = postfix&#xD;&#xA;table = alias&#xD;&#xA;select_field = goto&#xD;&#xA;where_field = address&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;mysql_virtual_domains_maps.cf&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;user = postfix&#xD;&#xA;password = SecretPassword!&#xD;&#xA;hosts = localhost&#xD;&#xA;dbname = postfix&#xD;&#xA;table = domain&#xD;&#xA;select_field = domain&#xD;&#xA;where_field = domain&#xD;&#xA;additional_conditions = and backupmx = &apos;0&apos; and active = &apos;1&apos;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;mysql_virtual_mailbox_maps.cf&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;user = postfix&#xD;&#xA;password = SecretPassword!&#xD;&#xA;hosts = localhost&#xD;&#xA;dbname = postfix&#xD;&#xA;table = mailbox&#xD;&#xA;select_field = maildir&#xD;&#xA;where_field = username&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;If you want to be be able to relay mail through your server with SMTP AUTH, setup the following in /etc/postfix/sasl/smtpd.conf:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;pwcheck_method: auxprop&#xD;&#xA;mech_list: PLAIN LOGIN&#xD;&#xA;auxprop_plugin: sql&#xD;&#xA;sql_verbose: yes&#xD;&#xA;sql_engine: mysql&#xD;&#xA;sql_hostnames: localhost&#xD;&#xA;sql_user: postfix&#xD;&#xA;sql_passwd: postfix&#xD;&#xA;sql_database: postfix&#xD;&#xA;sql_select: select password from mailbox where username = &apos;%u@%r&apos;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Create the directory structure, including a directory for the first domain. You&apos;ll also want to go into PostfixAdmin and create a &apos;test&apos; account for the yourdomain.com to match this.&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;mkdir -p /home/vmail/yourdomain.com/test&#xD;&#xA;chmod -R 770 /home/vmail&#xD;&#xA;chown -R postfix:postfix /home/vmail/&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Install Dovecot with MySQL support&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;apt-get install dovecot-common dovecot-imapd dovecot-pop3d&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Configure the Dovecot/MySQL setup in /etc/dovecot/dovecot-mysql.conf using these settings:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;driver = mysql&#xD;&#xA;connect = dbname=postfix user=postfixadmin host=localhost password=SecretPassword!&#xD;&#xA;default_pass_scheme = PLAIN&#xD;&#xA;password_query = SELECT password FROM mailbox WHERE username = &apos;%u&apos;&#xD;&#xA;user_query = SELECT maildir, 106 AS uid, 106 AS gid FROM mailbox WHERE username  = &apos;%u&apos;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Then configure Dovecot to use MySQL by setting these options in /etc/dovecot/dovecot.conf:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;protocols = imap imaps pop3 pop3s&#xD;&#xA;disable_plaintext_auth = no&#xD;&#xA;log_timestamp = &quot;%Y-%m-%d %H:%M:%S &quot;&#xD;&#xA;mail_location = maildir:/home/vmail/%d/%n&#xD;&#xA;mail_access_groups = mail&#xD;&#xA;first_valid_uid = 106&#xD;&#xA;first_valid_gid = 106&#xD;&#xA;protocol imap {&#xD;&#xA;}&#xD;&#xA;  &#xD;&#xA;protocol pop3 {&#xD;&#xA;  pop3_uidl_format = %08Xu%08Xv&#xD;&#xA;}&#xD;&#xA;auth default {&#xD;&#xA;  mechanisms = digest-md5 plain&#xD;&#xA;  passdb sql {&#xD;&#xA;    args = /etc/dovecot/dovecot-mysql.conf&#xD;&#xA;  }&#xD;&#xA;  userdb sql {&#xD;&#xA;    args = /etc/dovecot/dovecot-mysql.conf&#xD;&#xA;  }&#xD;&#xA;  user = root&#xD;&#xA;}&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Restart Dovecot and Postfix and test it all out.&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;At the end of it, you should be able to add new domains, mailboxes and aliases using PostfixAdmin and have it all work properly, including SMTP authentication. Note that you don&apos;t need saslauthd for SMTP authentication to work.</s:content>
        <s:mTime>2008-06-11 05:11:37.0</s:mTime>
        <s:cTime>2008-05-29 16:29:22.0</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail'/>
                <rdf:li rdf:resource='#snipsnap-search'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/postfixadmin on debian sarge'/>
                <rdf:li rdf:resource='#snipsnap-index'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/Postfix mbox to Maildir conversion'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/mass emailing best practices'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/Mail and DNS'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/miscapplications/ruby on rails'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/mail not going through'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/Security/Securing Your Server'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/misc/ajax autocomplete'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/postfixadmin on RHEL4'/>
                <rdf:li rdf:resource='#knowledgebase'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#virtualmin notes'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/distros/debian'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/misc/deprecated'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/Security/preventing-brute-force-ssh-attacks'/>
            </rdf:Bag>
        </s:snipLinks>
        <s:attachments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
    </s:Snip>
</rdf:RDF>
