Warung Bebas

Saturday, February 25, 2012

Membuat Mail Server + Virtual Domain di Ubuntu


KALI INI KITA AKAN MEMBUAT MAIL SERVER DENGAN UBUNTU 9.10

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

1
root@kaitokid:~# mysql -u root -p // -p masukkan passwd mysql nya
1
<em>mysql&gt; create database postfix; mysql&gt; grant all privileges on postfix.* to 'postfix'@'localhost' identified by 'postfixpassword'; mysql&gt; grant all privileges on postfix.* to 'postfix'@'127.0.0.1' identified by 'postfixpassword'; mysql&gt; exit</em>
1
2
// ganti 'postfixpasswd' sesuai pasword yang di inginkan &amp; 'postfix'
sesuai dengan user yang dinginkan

5. Download postfixadmin untuk mempermudah administrasi mail

1
<em> http://sourceforge.net/projects/postfixadmin/</em>

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

1
<em> 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</em>

7. Setup config.inc.php postfixadmin

root@kaitokid:~# nano /var/www/postfix/config.inc.php
1
2
3
4
5
6
7
8
9
// 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
1
2
3
4
5
6
7
8
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
1
2
3
4
5
6
7
8
9
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'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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'
1
2
3
4
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
}
1
2
3
4
5
6
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 em “Membuat Mail Server + Virtual Domain di Ubuntu”

Post a Comment

 

Indahnya Berbagi Copyright © 2012 Fast Loading -- Powered by Blogger