S0t4's Blog

Hanya Catatan dan Mencoba Untuk Berbagi

Monday, November 8, 2010

Langkah Simple Seting Mail Server Pakai Postfix di Ubuntu Gak Sampai 5 menit...

  Blogger Sejati       Monday, November 8, 2010
Langsung saja ya...Asumsi anda sudah install DNS server dengan MX
misal contoh pakai mydomain.com, format mailbox adalah Maildir di masing-masing user linux.

I. Instal Paket Pendukung
1. #sudo apt-get install postfix
2. #sudo apt-get install mailutils

II. Test Default Setup
1. Buat user linux sekaligus debagai user email
#sudo useradd -m -s /bin/bash fmaster
#sudo passwd fmaster
(isi password sesuai keinginan)

2. Test mail
#telnet localhost 25

Jika tidak mau cek apakah postfixnya sudah jalan
#sudo postfix status
Kalau belum runing
#sudo postfix start

Kalau tidak ada masalah maka setelah telnet akan keluar
Trying 127.0.0.1...
Connected to mail.fossedu.org.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix (Ubuntu)

3. Ketikkan command berikut
ehlo localhost
mail from: root@localhost
rcpt to: fmaster@localhost
data
Subject: My first mail on Postfix

Hi,
Are you there?
regards,
Admin
. (Type the .[dot] in a new Line and press Enter )
quit

4. Check mailbox dari fmaster
#su - fmaster
mail

Nanti akan keluar
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/fmaster": 2 messages 2 new
>N 1 root@localhost Mon Mar 6 12:49 13/479 Just a test
N 2 root@localhost Mon Mar 6 12:51 15/487 My first mail
&

OK berarti semua berjalan normal... Lanjut

III. Seting Postfix Support Maildir_style Mailbox

1. #sudo postconf -e "home_mailbox = Maildir/"
2. #sudo postconf -e "mailbox_command = "
3.Restart Postfix
#sudo /etc/init.d/postfix restart

Selanjutnya test Kirim email lagi (ikuti langkah di bagian II).
Kalau berhasil di home directory fmaster (/home/fmaster) akan ada folder Maildir

4. Copy folder Maildir di /home/fmaster ke /etc/skel, supaya nanti setiap create user linux otomatis Maildir tercreate (optional, bisa dilakukan bisa tidak).
#sudo cp -R /home/fmaster/Maildir /etc/skel

IV. Install Courier IMAP dan POP3

1. #sudo apt-get install courier-pop
2. #sudo apt-get install courier-imap
3. #sudo apt-get install courier-pop-ssl (u/ support ssl port 995)


V. Tambah Local Domain ke Postfix

1. #sudo postconf -e "mydestination = mail.mydomain.com, mydomain.com, localhost,localhost.localdomain"
2. Tambah juga local networknya
#sudo postconf -e "mynetworks = 127.0.0.1, 192.168.1.0/24 (asumsi network lokal anda 192.168.1.0)
3. Buat postfix bisa terima email di semua interface network
#sudo postconf -e "inet_interfaces = all"
4. Isi protocol yang dipakai
#sudo postconf -e "inet_protocols = all"
5. Restart Postfix
#sudo /etc/init.d/postfix restart
6. Test Postfix lagi
#netcat mail.mydomain.com 25 atau netcat [ip server mail] 25
ehlo mydomain.com
mail from: root@mydomain.com
rcpt to: fmaster@mydomain.com
data
Subject: My first mail for my domain

Hi,
Are you there?
regards,
Admin
. (and Enter In a new Line)
quit
Check the mailbox of fmaster
su - fmaster
cd Maildir/new
ls

7. Check mailbox fmaster
#su - fmaster
#cd Maildir/new
#ls

Akan ada email masuk....


VI. Test Courier POP3

1. netcat mail.mydomain.com 110
Connected to mail.yourdomain.com (208.77.188.166).
Escape character is '^]'.
+OK Hello there.

2. Ketik hal berikut
user fmaster
+OK Password required.
pass password
+OK logged in.
quit

OK semua beres tinggal buat user email yang lain lagi, caranya sama dengan create user linux
#sudo adduser -m -s /bin/bash [namauser]
#sudo passwd [namauser]

VII. Optional

A. Local Alias database

When mail is to be delivered locally, the local delivery agent runs each local recipient name through the aliases database. The mapping does not affect addresses in message headers. Local aliases are typically used to implement distribution lists, or to direct mail for standard aliases such as postmaster to real people. The table can also be used to map Firstname.Lastname addresses to login names.
Alias lookups are enabled by default and you will see following code segment in main.cf file.
...
alias_maps = hash:/etc/aliases
...
Creating an alias for an account
The following codes illustrate how you can setup an alias. This step is optional since we are going to configure virtual mail domains later in this howto. I have added this step to make sure you understand how you can do this in case it is required.

Create a user
#sudo useradd -m -s /bin/bash sysadmin
#sudo passwd sysadmin
Edit the alias table
Open the alias file with:
#sudo vi /etc/aliases
Add the following code:
#fmaster: sysadmin
To make your changes take effect type:
#sudo newaliases

To test your changes send a mail to fmaster and check the mail in /home/sysadmin/Maildir/new folder.

B. Per User .forward Files

Users can control their own mail delivery by specifying destinations in a file called .forward in their home directories. The syntax of these files is the same as system aliases, except that the lookup key and colon are not present.
I will illustrate an example here:
Assume that you need to forward all the mails which come to the sysadmin account to an another account. Enter the following commands:
#su - sysadmin
#touch .forward
Then open the .forward file
#vi .forward
Add the following code:
#fossedu@example.com
Remember to use email address which exists in this exercise.
Now send a mail to sysadmin and mail should come to fossedu@example.com

C. Postfix virtual Aliases for separate domains and Linux system accounts

With this approach, every hosted domain can have its own info etc. email address. However, it still uses Linux system accounts for local mailbox deliveries.
With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address. The example below shows how to use this mechanism for the fossedu.org and linuxelabs.com domains.
Inside the main.cf file, we tell it how to handle these virtual domains:

#sudo postconf -e "virtual_alias_domains = fossedu.org linuxelabs.com"
#sudo postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

Edit the /etc/postfix/virtual file:
Add two Linux system accounts
#sudo useradd -m -s /bin/bash sigiri
#sudo useradd -m -s /bin/bash kala

Set passwords for the above users.
#sudo passwd sigiri
#sudo passwd kala
#sudo vi /etc/postfix/virtual

Add the following code segment:
#info@fossedu.org sigiri
#info@linuxelabs.com kala

To create a Map Database type :
#sudo postmap /etc/postfix/virtual
postmap is utility program that will convert /etc/postfix/virtual to /etc/postfix/virtual.db in Berkley DB format, so that Postfix can access the data faster.
Restart Postfix to make changes take effect:
#sudo /etc/init.d/postfix restart


Tambahan konfigurasi lain bisa dibaca disini ya...


VIII. Seting Client Outlook Express

Dari Menu Outlook Express ikuti langkah berikut:
1. Tools > Account > mail
2. Add > mail
3. Isi display name dengan Nama lengkap kamu.
4. Next
5. Isi Email Address misal fmaster@mydomain.com
6. isi incomming mail POP dan SMTP dengan nama/Ip mail server kita
misal : mail.mydomain.com atau 192.168.1.1
7. Isi Account name tanpa domain name. misal :fmaster
8. Isi password sesuai password yang dicreate untuk user fmaster
9. Finish.

Coba kirim dan terima email ke fmaster@mydomain.com
logoblog

Thanks for reading Langkah Simple Seting Mail Server Pakai Postfix di Ubuntu Gak Sampai 5 menit...

Previous
« Prev Post

No comments: