Install and basic settings of the Postfix mail server in Ubuntu

Source: Internet
Author: User
Tags imap

After a long time, I wasted a lot of time and finally set up the Postfix email server in Ubuntu... However, even if there is no corn, it can only be replaced by an intranet IP address within the virtual machine.

Specific operations:

= ==========

Install Postfix

Sudo apt-Get install Postfix

Install the mailx package.MAIL command email ToolOfProgram. Install this package to install the MAIL command.

Sudo apt-Get install mailx

Test the default installation

Add a user.

Sudo useradd-m-S/bin/bash fmaster
Sudo passwd fmaster

Use the following command to test the default installation.

Telnet localhost 25

Postfix will display the following terminal prompt, so that you can enter some SMTP commands.

Trying 127.0.0.1...
Connected to mail.fossedu.org.
Escape Character is '^]'.
220 localhost. localdomain ESMTP Postfix (UBUNTU)

Enter these at the Postfix promptCode.

 
EHLO localhostmailFrom: Root @ localhostrcpt to: fmaster @ localhostdatasubjet: My first mail on postfixhi, are you there? Regards, admin. (type the. [Dot]InA new lineAndPress ENTER) quit

 

Check the mailbox of 'fmaster.

Su-fmaster
Mail

When you enterMail} The terminal output is as follows.

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 13/479 just a test
N 2 root @ localhost mon Mar 6 15/487 my first mail
&

You will observe that the email isIndex by number, so you can enter the number of the email you want to view. For example, enter '2' to read the second message. After reading, run the "Q" command to exit.The email will be written to a file named 'mbox' in the user's home directory. In our example, It is '/home/fmaster/mbox '.

In an mbox mailboxAll messages are connected and stored as a single file.. The beginning of each message is marked by the line with the first five letters "from", and there is a blank line at the end of each message.
Set Postfix to support maildir-type mailboxes

Maildir is the format of a mail pool.You do not need to lock the file to ensure the integrity of the message, because the mail is saved in individual files with a unique name. A maildir is a directory containing three sub-directories named TMP, new, and curd (often named in maildir ). These subdirectories should be in the same file system.

Another reason for using the maildir format isCourier IMAP/POP3 servers only support mailboxes in maildir format.

[Here] We can get more information about maildir.

Sudo VI/etc/Postfix/Main. cf

Add the following code:

Home_mailbox = maildir/

In'Mailbox_command = procmail-a "$ extension" 'added a "#" before the line to comment it out.

Restart Postfix to make the change take effect.

Sudo/etc/init. d/Postfix restart

Test your installation again.
Install courier IMAP and POP3

Sudo apt-Get install courier-pop
Sudo apt-Get install courier-imap

PostfixAdd local region

Sudo VI/etc/Postfix/Main. cf

Add your domain name to 'mydestination '. After adding it, it looks like this:

...
Mydestination= Mail.fossedu.org, localhost. localdomain, localhost,Yourdoamin.com
...

Change yourAdd local network:

Sudo VI/etc/Postfix/Main. cf

Assume that your local network is 192.168.1.0/24 and your local network is added to {mynetworks }}}. After completion, it looks like this:

Mynetworks = 127.0.0.0/8, 192.168.1.0/24

Enable Postfix to receive emails from the Internet

Use the following command to add 'inet _ interfaces = all' in '/etc/Postfix/Main. Cf'

Sudo VI/etc/Postfix/Main. cf

Restart Postfix;

Sudo/etc/init. d/Postfix restart

Use the following code to test whether your installation is successful again:

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 emails in separate files.
Test courier POP3

Enter:

Telnet mail.yourdomain.com 110

Use the following sample code for testing. Be sure to make appropriate changes in your own environment. The output should be as follows:

Connected to mail.yourdomain.com (69.60.109.217 ).
Escape Character is '^]'.
+ OK Hello there.

Enter the following code segment at the courier POP3 server prompt. I suppose you can enter the rows after '+ OK' according to the situation.

User fmaster
+ OK Password required.
Pass password
+ OK logged in.
Quit

Test courier IMAP

Enter these in the terminal:

Telnet mail.yourdomain.com 143

Use the following sample code for testing. Be sure to make appropriate changes in your own environment. The output should be as follows:

* 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.

Enter the following code segment at the courier POP3 server prompt

A login fmaster Password
A OK login OK.
A logout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.