----------------------------------------
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 it will be /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 here
sudo vi /etc/postfix/main.cf
Add the following code segment:
home_mailbox = Maildir/
Comment the Line mailbox_command = procmail -a "$EXTENSI
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-imap
= 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. An output like follows will display in your terminal.
Connected to mail.yourdomain.com (69.60.109.217).
Escape character is '^]'.
+OK Hello there.
Type the following code segment in the prompt provided by the Courier POP3 server. I assume that you inetligent enough not to type the lines which starts from +OK
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. An output like follows will display in your terminal.
* 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.
Type the following code segment in the prompt provided by the Courier IMAP server.
a login fmaster password
a OK LOGIN Ok.
a logout
----------------------------------------它的用户管理用的就是linux操作系统的用户系统,所有创建一个linux用户也就
文档介绍了更多, 但是我只用到这个程度,也就是文档看到这里基本上就可以配置一个可用的邮件服务器了。
No comments:
Post a Comment