Membuat Mail Server + Virtual Domain di Ubuntu

Tuesday, December 13, 2011



apache2 , mysql , postfix, dovecot , squirellmail senjata utamanya :)
postfix adalah sebuah program pengirim email sebagai pengganti dari sendmail.
Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail.
It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA. (wiki)
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems, written primarily with security in mind. Developed by Timo Sirainen, Dovecot was first released in July 2002. Dovecot primarily aims to be a lightweight, fast and easy to set up open source mailserver. (wiki)
1. Persiapan sistem untuk Ubuntu 9.10
Agar nantinya tidak terdapat broken system alangkah baek nya install ubuntu dengan build essential
sudo apt-get install build-essential

2. Install file utama

sudo apt-get install postfix postfix-msql php5-imap dovecot-pop3d dovecot-imapd
php5-mysql squirrelmail apache2

3. Cek system apakah apache2 postfix dan dovecot ny udah ada lum disystem

service apache2 status && service postfix status && service dovecot status

4. Buat Database Untuk Postfix

  root@kaitokid:~# mysql -u root -p     // -p masukkan passwd mysql nya
  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
  // ganti 'postfixpasswd' sesuai pasword yang di inginkan & 'postfix'
sesuai dengan user yang dinginkan

5. Download postfixadmin untuk mempermudah administrasi mail

 http://sourceforge.net/projects/postfixadmin/

6. Extract hasil download postfixadmin dan pindahkan ke /var/www

 root@kaitokid:~# cd /var/www/ root@kaitokid:/var/www# tar xzf /home/kaitokid/postfixadmin-2.**.tar.gz root@kaitokid:/var/www# mv postfixadmin-2.**/ postfix root@kaitokid:/var/www# chown -R www-data.www-data /var/www

7. Setup config.inc.php postfixadmin

root@kaitokid:~# nano /var/www/postfix/config.inc.php
   // Database Config
// mysql = MySQL 3.23 and 4.0
// mysqli = MySQL 4.1
// pgsql = PostgreSQL
$CONF['database_type'] = 'mysqli'; //sesuaikan dg sql nya untuk mysql seri 4 keatas gunakan mysqli
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix'; // user database di mysql lihat nomer 4
$CONF['database_password'] = 'postfixpassword'; // user database mysql lihat nomer 4
$CONF['database_name'] = 'postfix'; $CONF['database_prefix'] = ''; //default kosong

8. Setup postfix admin

buka web browser firefox kemudian buka URL
http://127.0.0.1/postfix/setup.php
// waktu instalasi pastikan tidak ada error & untuk ppostfixadmin series 2.3 file setup tidak perlu dihapus
//pastikan web server di komputer udah jalan

9. Konfigurasi MySQL postfix

//konfigurasi user & passwd sesuai dg nomer 4
nano /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
nano /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'
nano /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'

nano /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'

nano /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'
  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

10. konfigurasi postfix main.cf

   nano /etc/postfix/main.cf
# Virtual Mailbox Domain Settings
//konfigurasi default main.cf untuk opreknya tunggu di part 2 mail server

myhostname = ubuntu //sesuaikan dg hostname komputer yang dipakai mail server
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_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
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
11. Konfigurasi Dovecot POP3 dan IMAP4
nano /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
}
nano /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'
ok sampai disini dulu happy mailing and happy ubuntu :)

0 comments:

Post a Comment