PostfixBasicSetupHowto
7064
Comment:
|
7459
|
Deletions are marked like this. | Additions are marked like this. |
Line 91: | Line 91: |
You will observe that mails are indexed by numbers and you can type the number of which the mail that you want to read. For example type no {{{2}}} to read t By def |
You will observe that mails are indexed by numbers and you can type the number of which the mail that you want to read. For example type no {{{2}}} to read the 2nd mail. The type {{{q}} to quit. The mail will be written to a file called {{{mbox}} in user's home directory. According to our example {{{/home/fmaster/mbox}}}. All messages in an mbox type of mailbox are concatenated and stored in a single file. The beginning of each message is indicated by a line whose first five characters are "From " and a blank line is appended to the end of each message |
ContentsBRTableOfContents |
Introduction
This howto will help you to have a basic Postfix mail server setup for your corporate environment. The main intention of this howto is to teach how you can install and configure a basic Postfix mail server setup with IMAP and POP3 services. I do not intend to tell you how you can integrate advanced stuffs like virus checking and spam filtering with this guide. My advanced postfix guide is CompleteVirtualPostfixIspMailSetup. Enjoy it once you have finished this basic howto.
System Overview
In our setup, Postfix sends & retrieves mail from Internet and stores in the user mail boxes while clients in the Internet can retrieve their mails either from Courier IMAP or POP3. The user authentication is done by Courier Authdaemon. The following diagram shows this process.
attachment:PostfixSetupOverview.jpg
Install Postfix
In this setup I assume that your domain is yourdomain.com and it has a valid MX record call mail.yourdomain.com. Remember to replace yourdomain.com with your actual domain in the example codes in this howto. Also I assume that you know what an MX record is. To find out MX your type in a terminal:
dig mx yourdomain.com
To install postfix
sudo apt-get install postfix
Intall mailx package for use as command mail utility program. Mail command is installed with this package.
sudo apt-get install mailx
Test your default setup
Add a user before you start this.
sudo useradd -m -s /bin/bash fmaster sudo passwd fmaster
Test your default installation using the following code segment.
telnet localhost 25
Postfix will prompt like following in the terminal so that you can use to type SMTP commands.
Trying 127.0.0.1... Connected to mail.fossedu.org. Escape character is '^]'. 220 localhost.localdomain ESMTP Postfix (Ubuntu)
Type the following code segment in Postfix's prompt.
ehlo localhost mail from: root@localhost rcpt to: fmaster@localhost data Subjet: My first mail on Postfix Hi, Are you there? regards, Admin . (Type the .[dot] in a new Line and press Enter ) quit
Check the mailbox of fmaster
su - fmaster mail
When your type mail command an output like follows display in your terminal.
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 &
You will observe that mails are indexed by numbers and you can type the number of which the mail that you want to read. For example type no 2 to read the 2nd mail. The type q}} to quit. The mail will be written to a file called {{{mbox}} in user's home directory. According to our example {{{/home/fmaster/mbox.
All messages in an mbox type of mailbox are concatenated and stored in a single file. The beginning of each message is indicated by a line whose first five characters are "From " and a blank line is appended to the end of each message
Setting Postfix Support for Maildir-style Mailboxes
Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.
Another reason to use Maildir format is that Courier IMAP/POP3 servers only work with Maildir format of mailboxes.
Please find out more about Maildir [http://en.wikipedia.org/wiki/Maildir here]
sudo vi /etc/postfix/main.cf
Add the following code segment:
home_mailbox = Maildir/
Comment the Line mailbox_command = procmail -a "$EXTENSION" adding a "#" at the beginning
Restart Postfix to make changes effect.
sudo /etc/init.d/postfix restart
Test your setup again
Installing courier IMAP and POP3
sudo apt-get install courier-pop sudo apt-get install courier-pop-ssl sudo apt-get install courier-imap sudo apt-get install courier-imap-ssl
= Adding local domains to postfix
sudo vi /etc/postfix/main.cf
Add your domain to:
sudo vi /etc/postfix/main.cf
Add your domain to mydestination. Once added it should be like the following code segment.
... mydestination = mail.fossedu.org, localhost.localdomain, localhost, yourdoamin.com ...
Add your local network to:
sudo vi /etc/postfix/main.cf
I assume that your local network is 192.168.1.0/24 and add your local network to mynetworks. Once added it should be like the following code segment.
mynetworks = 127.0.0.0/8, 192.168.1.0/24
Make Postfix to receive mail from the Internet
Set inet_interfaces = all in /etc/postfix/main.cf using:
sudo vi /etc/postfix/main.cf
Finally Restart Postfix;
sudo /etc/init.d/postfix restart
Test your setup again using following code:
telnet mail.yourdomain.com 25 ehlo yourdmain.com mail from: root@yourdomain.com rcpt to: fmaster@yourdomain.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
Now you will see mail has a separate file
Testing Courier POP3
Type in a terminal:
telnet mail.yourdomain.com 110
Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment.
Connected to mail.yourdomain.com (69.60.109.217). Escape character is '^]'. +OK Hello there. user fmaster +OK Password required. pass password +OK logged in. quit
Testing Courier IMAP
Type in a terminal:
telnet mail.yourdomain.com 143
Use the following example code segment for your test. Be intelligent to tweak the changes appropriately to your environment.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS XCOURIEROUTBOX=INBOX.Outbox] Courier-IMAP ready. Copyright 1998-2005 Double Precision, Inc. See COPYING for distribution information. a login fmaster password a OK LOGIN Ok. a logout
Adding TLS (Transport Layer Security)
Transport Layer Security (TLS), its successor, are cryptographic protocols which provide secure communications on the Internet. Using this we tell Postfix to authenticate when they are sending mail. This will provide a way to secure our mails and stop un-authorized relaying etc.
Please find out more about TLS [http://en.wikipedia.org/wiki/Transport_Layer_Security here]
To add TLS support for postfix:
sudo apt-get install postfix-tls
Howto created by: ChinthakaDeshapriya.
PostfixBasicSetupHowto (last edited 2008-08-06 17:00:10 by localhost)