Cara Buat Intramail Dengan Postfix admin di Linux

Postfix + Courier POP + Courier IMAP + Squirrelmail + PostfixAdmin

————————————————————————————————————————

Instal MySQL Server

# apt-get install mysql-server-5.0 mysql-client-5.0

Download PostfixAdmin & Membuat Database

# wget http://optusnet.dl.sourceforge.net/sourceforge/postfixadmin/postfixadmin-2.1.0.tgz

# tar -xzvf postfixadmin-2.1.0.tgz

# mysqladmin -u root password ‘rahasia’

# mysql -u root -p < DATABASE_MYSQL.TXT

Mengisi Tabel

# mysql -u postfix -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.0.51-3 (Debian)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use postfix;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> INSERT INTO domain(domain,description) VALUES (“sekargroup.com”,”Domain Utama”);

Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO alias(address,goto) VALUES (“postmaster@sekargroup.com”,”cahyo@sekargroup.com”);

Query OK, 1 row affected (0.00 sec)

mysql> quit;

Bye

Konfigurasi PostfixAdmin

# cp postfixadmin-2.1.0 /var/www/postfixadmin-2.1.0

# cd /var/www/postfixadmin-2.1.0/

# mv config.inc.php.sample config.inc.php

Kemudian akses postfixadmin admin via browser dengan alamat localhost/postfixadmin-2.1.0/admin/ dan tambahkan 1 user (add mailbox) dengan user cahyo.

Instal Postfix (SMTP Server)

# wget http://vda.sourceforge.net/VDA/postfix-2.4.6-vda-ng.patch.gz

# wget http://ftp.debian.org/debian/pool/main/p/postfix/postfix_2.4.6.orig.tar.gz

# wget http://ftp.debian.org/debian/pool/main/p/postfix/postfix_2.4.6-4.diff.gz

# wget http://ftp.debian.org/debian/pool/main/p/postfix/postfix_2.4.6-4.dsc

# wget http://ftp.debian.org/debian/pool/main/c/cyrus-sasl2/cyrus-sasl2_2.1.22.dfsg1.orig.tar.gz

# wget http://ftp.debian.org/debian/pool/main/c/cyrus-sasl2/cyrus-sasl2_2.1.22.dfsg1-8.dsc

# wget http://ftp.debian.org/debian/pool/main/c/cyrus-sasl2/cyrus-sasl2_2.1.22.dfsg1-8.diff.gz

Patching & Build Package Postfix

# dpkg-source -x postfix_2.4.6-4.dsc

# cd postfix-2.4.6/

# zcat ../postfix-2.4.6-vda-ng.patch.gz | patch -p1

# dpkg-buildpackage

# ls -l

-rw-r–r– 1 capung capung 1984 2008-03-04 10:39 postfix_2.4.6-4_i386.changes

-rw-r–r– 1 capung capung 1120896 2008-03-04 10:38 postfix_2.4.6-4_i386.deb

-rw-r–r– 1 capung capung 38810 2008-03-04 10:38 postfix-cdb_2.4.6-4_i386.deb

-rw-r–r– 1 capung capung 134898 2008-03-04 10:39 postfix-dev_2.4.6-4_all.deb

-rw-r–r– 1 capung capung 830650 2008-03-04 10:39 postfix-doc_2.4.6-4_all.deb

-rw-r–r– 1 capung capung 45778 2008-03-04 10:38 postfix-ldap_2.4.6-4_i386.deb

-rw-r–r– 1 capung capung 40806 2008-03-04 10:38 postfix-mysql_2.4.6-4_i386.deb

-rw-r–r– 1 capung capung 40532 2008-03-04 10:38 postfix-pcre_2.4.6-4_i386.deb

-rw-r–r– 1 capung capung 40846 2008-03-04 10:38 postfix-pgsql_2.4.6-4_i386.deb

Hapus Paket Exim4

# dpkg -P –force-all exim4 exim4-base exim4-config exim4-daemon-light

Instal Paket Hasil BuildPackage

# dpkg -i postfix_2.4.6-4_i386.deb postfix-mysql_2.4.6-4_i386.deb

Konfigurasi Postfix

# addgroup –gid 666 vmailbox

Adding group `vmailbox’ (GID 666) …

Done.

# adduser –system –home /var/mailbox –shell /bin/false –uid 666 –gid 666 vmailbox

Adding system user `vmailbox’ (UID 666) …

Adding new user `vmailbox’ (UID 666) with group `vmailbox’ …

Creating home directory `/var/mailbox’ …

# id vmailbox

uid=666(vmailbox) gid=666(vmailbox) groups=666(vmailbox)

# vim /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)

biff = no

append_dot_mydomain = no

readme_directory = no

myhostname = mail.sekargroup.com

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

mydestination = debian, mail.sekargroup.com, localhost

relayhost =

mynetworks = 127.0.0.0/8

mailbox_size_limit = 0

recipient_delimiter = +

inet_interfaces = all

# setting virtual domain yang disimpan dalam database MySQL

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_gid_maps = static:666

# direktori awal mailbox user, sesuai dengan home direktori

# user vmailbox. Maildir tiap user akan terletak dalam direktori

# /var/mailbox/[info direktori maildir user dari database]

virtual_mailbox_base = /var/mailbox

virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

virtual_mailbox_limit = 51200000

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

virtual_minimum_uid = 666

virtual_transport = virtual

virtual_uid_maps = static:666

# Tambahan untuk quota

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, this user has reach mailbox quota limit.

virtual_overquota_bounce = yes

# vim /etc/postfix/mysql_virtual_alias_maps.cf

user = postfix

password = postfix

hosts = 127.0.0.1

dbname = postfix

query = SELECT goto FROM alias WHERE address=’%s’ AND active = 1

# vim /etc/postfix/mysql_virtual_domains_maps.cf

user = postfix

password = postfix

hosts = 127.0.0.1

dbname = postfix

query = SELECT domain FROM domain WHERE domain=’%s’

#optional query to use when relaying for backup MX

#query = SELECT domain FROM domain WHERE domain=’%s’ and backupmx = ‘0’ and active = ‘1’

# vim /etc/postfix/mysql_virtual_mailbox_maps.cf

user = postfix
password = postfix
hosts = 127.0.0.1
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username=’%s’ AND active = 1

# vim /etc/postfix/mysql_virtual_mailbox_limit_maps.cf

user = postfix
password = postfix
hosts = 127.0.0.1
dbname = postfix
query = SELECT quota FROM mailbox WHERE username=’%s’

# vim /etc/postfix/mysql_relay_domains_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ and backupmx = ‘1’

# chmod 640 /etc/postfix/mysql_*

# chgrp postfix /etc/postfix/mysql_*

# /etc/init.d/postfix restart

Testing SMTP

# telnet localhost 25

Trying 127.0.0.1…

Connected to localhost.

Escape character is ‘^]’.

220 mail.sekargroup.com ESMTP Postfix (Debian/GNU)

EHLO mail.com

250-mail.sekargroup.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-STARTTLS

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

QUIT

221 2.0.0 Bye

Connection closed by foreign host.

Percobaan Kirim Email

# echo “coba email” | mail -s cobaKirim cahyo@sekargroup.com

# tail -f /var/log/mail.log

Mar 4 11:07:55 debian postfix/smtpd[10440]: lost connection after QUIT from localhost[127.0.0.1]

Mar 4 11:07:55 debian postfix/smtpd[10440]: disconnect from localhost[127.0.0.1]

Mar 4 11:07:56 debian postfix/qmgr[9810]: BDBBC8B798: from=<postmaster@sekargroup.com>, size=400, nrcpt=1 (queue active)

Mar 4 11:07:56 debian postfix/virtual[10446]: BDBBC8B798: to=<cahyo@sekargroup.com>, relay=virtual, delay=0.56, delays=0.52/0.02/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)

Mar 4 11:07:56 debian postfix/qmgr[9810]: BDBBC8B798: removed

Mar 4 11:08:41 debian postfix/pickup[9811]: C50EF8B79F: uid=0 from=<root>

Mar 4 11:08:41 debian postfix/cleanup[10444]: C50EF8B79F: message-id=<20080304040841.C50EF8B79F@mail.sekargroup.com>

Mar 4 11:08:41 debian postfix/qmgr[9810]: C50EF8B79F: from=<root@mail.sekargroup.com>, size=319, nrcpt=1 (queue active)

Mar 4 11:08:41 debian postfix/virtual[10446]: C50EF8B79F: to=<cahyo@sekargroup.com>, relay=virtual, delay=0.06, delays=0.04/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)

Mar 4 11:08:41 debian postfix/qmgr[9810]: C50EF8B79F: removed

Instalasi & Konfigurasi Courier

# apt-get install courier-authdaemon courier-authlib-mysql courier-imap courier-pop

# vim /etc/courier/authmysqlrc

MYSQL_CRYPT_PWFIELD password
MYSQL_DATABASE postfix
MYSQL_GID_FIELD ‘666’
MYSQL_HOME_FIELD ‘/var/mailbox’
MYSQL_LOGIN_FIELD username
MYSQL_MAILDIR_FIELD maildir
MYSQL_NAME_FIELD name
MYSQL_OPT 0
MYSQL_PASSWORD postfix
MYSQL_QUOTA_FIELD quota
MYSQL_SERVER 127.0.0.1
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_UID_FIELD ‘666’
MYSQL_USERNAME postfix
MYSQL_USER_TABLE mailbox

ubah parameter authmodulelist=”authpam” menjadi authmodulelist=”authmysql”

# vim /etc/courier/authdaemonrc

authmodulelist=”authmysql”

# /etc/init.d/courier-authdaemon restart

Stopping Courier authentication services: authdaemond.

Starting Courier authentication services: authdaemond.

Testing IMAP

# telnet localhost 143

Trying 127.0.0.1…

Connected to localhost.

Escape character is ‘^]’.

* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2005 Double Precision, Inc. See COPYING for distribution information.

a login cahyo@sekargroup.com surabaya

a OK LOGIN Ok.

a logout

* BYE Courier-IMAP server shutting down

2 OK LOGOUT completed

Connection closed by foreign host.

Testing POP3

# telnet localhost 110

Trying 127.0.0.1…

Connected to localhost.

Escape character is ‘^]’.

+OK Hello there.

user cahyo@sekargroup.com

+OK Password required.

pass surabaya

+OK logged in.

quit

+OK Bye-bye.

Connection closed by foreign host.

# apt-get install squirrelmail

# squirrelmail-configure

# ln -s /usr/share/squirrelmail/ /var/www/mail

Silahkan buka browser dan akses email ke alamat http://localhost/mail.

Selesai

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: