Lokasi Ardelindo Aples Depok


View Ardelindo Aples in a larger map

Senin, 06 Juli 2009

Ubuntu Virtual Domain Postfix Admin, Dovecot dan MySQL



Sekarang akan kita bahas cara membuat virtual domain dengan menggunakan postfix admin, dovecot dan database mysql.

Langkah yang perlu kita tempuh adalah:

1. Download source postfix admin di
http://sourceforge.net/projects/postfixadmin/

2. kemudian extraxt di direktori /var/www/
root@budi-desktop:~# cd /var/www/
root@budi-desktop:/var/www# tar xzf /home/ardelindo/Desktop/postfixadmin-2.2.1.1.tar.gz
root@budi-desktop:/var/www# mv postfixadmin-2.2.1.1/ postfix
root@budi-desktop:/var/www# chown -R www-data.www-data /var/www

3. Install aplikasi utama
root@budi-desktop:~# apt-get install postfix postfix-msql php5-imap dovecot-pop3d dovecot-imapd php5-mysql squirrelmail

4. Buat database postfix
root@budi-desktop:~# mysql
mysql> create database postfix;
mysql> grant all privileges on postfix.* to 'postfix'@'localhost' identified by 'postfixpassword';
mysql> grant all privileges on postfix.* to 'postfix'@'127.0.0.1' identified by 'postfixpassword';
mysql> exit

5. Setup config.inc.php postfixadmin
root@budi-desktop:~# vim /var/www/postfix/config.inc.php
// Database Config
// mysql = MySQL 3.23 and 4.0
// mysqli = MySQL 4.1
// pgsql = PostgreSQL
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfixpassword';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';

6. Setup postfix admin
buka web browser firefox kemudian buka URL
http://127.0.0.1/postfix/setup.php

setelah selesai hapus setup.php
root@budi-desktop:~# rm -fr /var/www/postfix/setup.php

7. Konfigurasi MySQL postfix
vim /etc/postfix/mysql_virtual_alias_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = alias
select_field = goto
where_field = address
vim /etc/postfix/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'
vim /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'
vim /etc/postfix/mysql_relay_domains_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and backupmx = '1'
vim /etc/postfix/mysql_virtual_domains_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'
chgrp postfix /etc/postfix/mysql_*.cf
chmod 640 /etc/postfix/mysql_*.cf
groupadd -g 5000 vmail
useradd -m -g vmail -u 5000 -d /home/vmail -s /bin/bash vmail


8. Konfigurasi /etc/postfix/main.cf
vim /etc/postfix/main.cf
# Virtual Mailbox Domain Settings

myhostname = ubuntu
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit = 51200000
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_transport = virtual

# Additional for quota support

virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the your maildir has overdrawn your diskspace
quota, please free up some of spaces of your mailbox try again.
virtual_overquota_bounce = yes
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination =
relayhost =
#mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks = all
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all


9. Konfigurasi Dovecot POP3 dan IMAP4
vim /etc/dovecot/dovecot.conf
protocols = imap pop3
disable_plaintext_auth = no
default_mail_env = maildir:/home/vmail/%u/
first_valid_uid = 5000
first_valid_gid = 5000

# SQL database

passdb sql {
# Path for SQL configuration file
args = /etc/dovecot/dovecot-sql.conf
}

# SQL database

userdb sql {
# Path for SQL configuration file
args = /etc/dovecot/dovecot-sql.conf
}
vim /etc/dovecot/dovecot-sql.conf
driver = mysql
connect = host=127.0.0.1 dbname=postfix user=postfix password=postfixpassword
default_pass_scheme = CRYPT
user_query = SELECT maildir, 5000 AS uid, 5000 AS gid FROM mailbox WHERE username = '%u'
password_query = SELECT password FROM mailbox WHERE username = '%u'


10. Test Dovecot POP3 dan IMAP4
/etc/init.d/dovecot restart
root@budi-desktop:~# telnet 127.0.0.1 110
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
+OK Dovecot ready.
user admin@beruk.com
+OK
pass 12345
+OK Logged in.
list
+OK 2 messages:
1 562
2 619
.
quit
+OK Logging out.
Connection closed by foreign host.
root@budi-desktop:~#


SMTP SASL AUTHENTICATION
apt-get install sasl2-bin libsasl2-modules-sql cyrus-clients-2.2
vim /etc/postfix/main.cf
smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks,
permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unauth_destination, check_policy_service
# modify the existing smtpd_sender_restrictions
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks,
reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
# then add these
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_path = /etc/postfix/sasl:/usr/lib/sasl2
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =

vim /etc/postfix/sasl/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login cram-md5 digest-md5
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: postfix
sql_passwd: postfixpassword
sql_database: postfix
sql_select: select passwd from mailbox where username='%u@%r' and active = 1

Tidak ada komentar:

Posting Komentar