主 選 單
 登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!
 版面風格

(10 個版面風格)
站長部落格 - lutuni 的日誌
 訂閱 lutuni 的日誌

2014/10/19
How To Install and Setup Postfix on Ubuntu 12.04

作者: lutuni (6:32 pm)
About Postfix
Postfix is a free, open source Mail Transfer Agent which works to route and deliver email.


Prerequisites
Before installing Postfix, you will need to have a Fully Qualified Domain Name pointing to the server that you will be using.

You can find instructions on that here:How to Set Up a Host Name with DigitalOcean

Install Postfix
Postfix can easily be installed through apt-get:

sudo apt-get install postfix
During the installation, you will see a dialogue box appear, asking you which kind of installation you would prefer. Select “Internet Site”.

Follow up by entering the name of your domain.

Once Postfix is installed there are a few steps that need to be taken before it is fully functional.

Configure Postfix
Once Postfix is installed, go ahead and open the main configuration file.

sudo nano /etc/postfix/main.cf
There are a few changes that should be made in this file.

myhostname = example.com
Put in name of your domain into myhostname.

If you want to have mail forwarded to other domains, replace alias_maps with virtual_alias_maps and point it to /etc/postfix/virtual.

virtual_alias_maps = hash:/etc/postfix/virtual
The rest of the entries are described below

mydestination defines the domains that postfix is going to serve, in this case—localhost and your domain (eg. example.com). relayhost can be left, as is the default, empty.

mynetworks defines who can use the mail server. This should be set to local—creating an open mail server is asking for SPAM. This will usually have damaging effects on your server and may put you in line for discipline from your web hosting provider.

If it is not set up by default, as it should be, make sure you have the following text on that line:

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
The rest of the lines are set by default. Save, exit, and reload the configuration file to put your changes into effect:

sudo /etc/init.d/postfix reload
Configure Additional Emails
To redirect emails to specific emails, you can add users to the alias file. By default each user on the server will be able to read emails directed to their username@domain-name.com.

Open up the the alias database:

sudo nano /etc/postfix/virtual
Within that file, enter in the names of your users. For example:

sales@example.com username1
me@example.com username2
Once you are finished, save, exit, and run the following command:

postmap /etc/postfix/virtual
The last step is to reload postfix once more.

sudo /etc/init.d/postfix reload
Conclusion
Once Postfix is installed, mail can be sent to and from the server, although without a mail server like Dovecot or Cyrus, you will only be able to see the email on the server.

You send out email from the command line with the command “sendmail” and where you want the mail sent to:

sendmail sample-email@example.org
Once you enter the command, type your message, and when it is completed, you can send it off with ctrl-D

Incoming mail gets delivered into /var/mail/username
閱讀 lutuni 的日誌 | 迴響 (0) | 引用次數 (0) | 瀏覽次數 (716)
本篇文章引用網址
http://123.204.89.156/etype/modules/weblog/weblog-tb.php/94
列印這一篇日誌 發送這篇日誌給你的朋友(Email)