1. 程式人生 > >suse架設postfix郵件伺服器

suse架設postfix郵件伺服器


環境:

Suse Linux Enterprise Server 11(x86_64) SP1

 Postfix 需要安裝的元件

套 件 名 稱

簡 單 描 述

postfix

SMTP Server 的主要套件。

qpopper

POP3 Server 的主要套件。

需先切到root使用者

zypper install postfix

suse使用qpopper來作為pop3工具,qpopper 自行下載

rpm -ivh qpopper-4.0.14-1.1.x86_64.rpm

Tips欲架設具認證功能的郵件主機時,尚需多裝 cyrus-saslcyrus-sasl-saslauthd

這兩個套件。

如果你沒有域名,可以通過下面:

1.修改郵件伺服器的hosts檔案

vim /etc/hosts   在檔案中新增
  1. 127.0.0.1   yourdomain.com      
2.修改測試客戶端的hosts檔案
以管理員許可權執行一個文字編輯器,開啟"C:\Windows\System32\drivers\etc\hosts",在裡面新增
  1. 192.168.0.114   yourdomain.com  

 檢視套件內容

suse:~ # rpm -ql postfix

/etc/postfix/main.cf

Postfix 的主要設定檔。

/etc/postfix/transport

擔任 Mail GW 的主機,可以藉由設定這個檔案,來將信件轉給指定的 MTA。

/etc/init.d/postfix

管理 Postfix 服務的 script。

/sbin/rcpostfix

連結至 /etc/init.d/postfix 的符號連結檔。

/usr/lib/postfix/master

提供 Postfix 服務的 daemon。

/usr/bin/mailq

查詢郵件佇列 (mail queue) 的指令。

/usr/bin/newaliases

建立或更新郵件別名資料庫。

/usr/sbin/postalias

維護 Postfix 別名資料庫。

/usr/sbin/postconf

Postfix 的設定工具。

/usr/sbin/postfix

控管 Postfix 的程式。

/usr/sbin/postmap

可將指定的檔案內容轉換成資料庫格式,並將轉換後的結果寫入資料庫檔案裡。

/usr/sbin/postsuper

管理佇列郵件的工具。

/var/spool/postfix

安置處理佇留信件的相關目錄,如 hold、incoming、active 及 deferred 等。

 針對此套件內容裡的 /usr/sbin/postconf 及 /usr/sbin/postfix指令做個補充:

/usr/sbin/postconf

此為 Postfix 的設定工具,可以用來列出 Postfix 的預設引數及實際引數值,也可以直接在命令列上編輯設定引數,並將結果寫入 main.cf 中。舉例如下:

suse:~ # postconf列出 Postfix 目前真實的設定引數值。

suse:~ # 
postconf -d列出 Postfix 預設的設定引數值。suse:~ #postconf -e 'alias_maps = hash:/etc/postfix/aliases'在命令列上編輯設定引數後,會直接寫入main.cf中。

/usr/sbin/postfix

這是 postfix 的控管程式,可用來啟動、停止、重新載入 postfix 服務。舉例如下:

suse:~ # postfix stop [start|reload]這應該沒問題。

suse:~ # 
postfix flush將佇留信件強迫寄出。


 設定開機時啟動 Postfix 服務

suse:~ # chkconfig postfix 35

17.3.2 設定簡易的 Postfix Server

 這一小節會先設定一些 Postfix 的基本引數,等 Postfix 能正常運作之後,再來進一步探討其他的引數設定。另外這裡是把 SMTP 及 POP3 Server 都架設在同一部主機上,這樣在實作上也會比較單純及方便。

 設定 SMTP Server

suse:/etc/postfix #vi main.cf

# The queue_directory specifies the location of the Postfix queue.
queue_directory = /var/spool/postfix 
這是佇留信件所存放的目錄位置。 # The command_directory parameter specifies the location of all postXXX commands. 
command_directory = /usr/sbin
指定所有 postxxx 指令 (如 postfix、postalias、postconf 等) 所存放的目錄位置。

# The daemon_directory parameter specifies the location of all Postfix daemon programs 
# (i.e. programs listed in the master.cf file). This directory must be owned by root. 
daemon_directory = /usr/lib/postfix
指定所有 Postfix 相關 daemon 所存放的目錄位置。

# The mail_owner parameter specifies the owner of the Postfix queue and of most 
# Postfix daemon processes.
mail_owner = postfix
指定 Postfix 佇列目錄的擁有者及大部分 Postfix daemon 程式的執行身分。

# The myhostname parameter specifies the internet hostname of this mail system.
# $myhostname is used as a default value for many other configuration parameters.
myhostname = mta.paching.idv.tw
指定您 Mail Server在 Internet 上的完整主機名稱。

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration parameters.
mydomain = paching.idv.tw
指定本地端的網域名稱,也就是把 $myhostname去除最前頭的 Short hostname 即是。
如果 myhostname 設定為 paching.idv.tw,那 mydomain 就是 idv.tw。
# For the sake of consistency between sender and recipient addresses,myorigin also
# specifies the default domain name that is appended to recipient addresses that
# have no @domain part.
myorigin = $mydomain
當您在 Postfix 主機上發信時,在對方收到信件後,會顯示寄件者的郵件地址為
[email protected][$myorigin],以這裡來說就是 [email protected]
另外要直接指派也行:myorigin = paching.idv.tw如果您有設定郵件別名 (參考 17.4 節) 時,也會使用到這個引數的設定。

# The inet_interfaces parameter specifies the network interface addresses that this mail
# system receives mail on. By default, the software claims all active interfaces on the 
# machine.
# Note: you need to stop/start Postfix when this parameter changes.
inet_interfaces = all
指定在郵件主機上,允許接收信件的網路介面位址。all是表示所有網路介面都可以
接收使用者所寄來的信件,這也是預設值。
另外當您修改了這個引數後,需要重新啟動 Postfix,而不是重新載入。

# The mydestination parameter specifies the list of domains that this machine considers 
# itself the final destination for. 
mydestination = $mydomain
Mail Server 是否會將此封信當成本地端的信件來處理,就是靠這個引數來決定的。比如以這裡的設定來說,只要收到的信件地址是 [email protected],則此 MTA 都會視為
#本地端的信件。如您有多個網域名稱時,在這些名稱之間可使用空白鍵或,隔開。

# By default (mynetworks_style = subnet), Postfix "trusts" SMTP clients in the same IP 
# subnetworks as the local machine. 
# Specify "mynetworks_style = class" when Postfix should "trust" SMTP clients in the
# same IP class A/B/C networks as the local machine. 
# Specify "mynetworks_style = host" when Postfix should "trust" only the local machine. 
mynetworks_style = subnet
#指定 SMTP所信任的來源端型別,至於可以指定的型別有以下三種:
#
 mynetworks_style = subnet#只要與 MTA位於同一個子網段的主機,其所寄過來的信件都允許 Relay。此乃預設。
#
 mynetworks_style = class#只要與 MTA位於同一 IP 型別 (Class A/B/C) 的主機,其所寄過來的信件都允許 Relay。 
#
 mynetworks_style = host #只允許本機 Relay,也就是隻能在郵件主機上來寄信的意思。

# Alternatively, you can specify the mynetworks list by hand, in which case Postfix ignores
# the mynetworks_style setting. 
# Specify an explicit list of network/netmask patterns, where the mask specifies the number
# of bits in the network part of a host address.
mynetworks = 192.168.1.0/24,127.0.0.0/8
指定 SMTP 所信任的來源端位址。以這裡的設定來說,只要是從 192.168.1.0/24 這個
網路段所寄過來的信件,或是直接在本機寄信時,都允許 Relay
#
另外當 mynetworks_style及 mynetworks 同時做設定時,mynetworks_style 會被忽略掉。

always_bcc = [email protected]
這個引數可將 postfix所有收發的信件,利用密件副本的方式寄給其後所指定的帳號。

message_size_limit = 10240000 
# 設定每封信件大小不得超過 10 MB

main.cf 中勿加home_mailbox=Mailbox/

不然telnet IP 110時,收不到郵件,會出現has 0 visible message 或者你使用outlook等客戶端時收不到郵件,

 以上就是一些基本的設定引數。如您 Postfix 目前尚未啟動,則請使用以下任何一種方式來啟動吧:

suse:~ #/etc/init.d/postfix start
suse:~ #
 rcpostfix start
suse:~ # 
postfix start

 將來要是作了任何的修改,那執行「rcpostfix restart」或「postfix reload」就行了。

 SMTP 啟動之後的檢查

1.    本機使用 netstat 或 ps 指令檢查

suse:~ # netstat -anp | grep :25
tcp
 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 11348/master
       這裡如果顯示 127.0.0.1 的話,表示不能對外提供 smtp 服務,請您特別留意一下。
suse:~ #
 ps aux | grep master
root
 11348 0.0 0.5 4736 1432 ? Ss 18:17 0:00 /usr/lib/postfix/master

2.     

3.    Client 端使用 telnet 測試

Windows Client 的測試

C:\> telnet 192.168.1.111 25

220 mta.paching.idv.tw ESMTP Postfix
看到這一行就對了。

Linux Client 的測試 (順便模擬與 SMTP 的對話)

Client:~ # telnet 192.168.1.111 25
Trying 192.168.1.111...
Connected to 192.168.1.111.
Escape character is '^]'.
220 mta.paching.idv.tw ESMTP Postfix
helo client.paching.idv.tw先使用 helo指令來介紹自己所在的主機。

250 mta.paching.idv.tw
mail from: [email protected]使用 mail from 指令來讓 SMTP Server 瞭解寄件者的郵件地址。

250 Ok
rcpt to: [email protected]使用 rcpt to 指令來讓 SMTP Server 知道收件者的郵件地址。
請務必確定郵件主機上存在著 mary 的帳號。

250 Ok
data使用 data 指令來表示開始要撰寫信件的內容了。

354 End data with <CR><LF>.<CR><LF>
subject: test這封信的主旨。以下就是信件的內容囉。Hello mary, i am barry.
How are you ?
.最後輸入個.,來表示信件已撰寫完畢。接著 SMTP就會開始處理您的信件了。

250 Ok: queued as 5F2155E6A
quit退出與 SMTP Server的對話。

221 Bye
Connection closed by foreign host.

 設定 POP3 Server

 目前這臺 Mail Server 只能提供寄信的服務,還不能提供給您的 Client 端收信,所以趕快去設定一下 POP3 就行了。POP3 服務是靠 xinetd 來啟動的,因此待會兒做完修改後,請記得重新啟動 xinetd。

suse:~ # vi /etc/xinetd.d/qpopper
service pop3
{
    disable    = no 原本為 yes,改成 no 即可。    socket_type  = stream
    protocol    = tcp
    wait      = no
    user      = root
    server     = /usr/sbin/popper
    server_args   = -s
    flags     = IPv4 


suse:~ # 
rcxinetd restart

 POP3 啟動之後的檢查

1.    本機使用 netstat 指令檢查

suse:~ # netstat -anp | grep :110
tcp
 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 12082/xinetd

2.     

3.    Client 端使用 telnet 測試

Windows Client 的測試

C:\> telnet 192.168.1.111 110

+OK ready <[email protected]>

Linux Client 的測試 (順便模擬與 POP3 的對話)

Client:~ # telnet 192.168.1.111 110
Trying 192.168.1.111...
Connected to 192.168.1.111.
Escape character is '^]'.
+OK ready <[email protected]>
user mary使用 user指令來指出您在 POP3 Server 上的帳號。

+OK Password required for mary.
pass mypasswd#使用 pass指令來輸入 mary 的密碼。

+OK mary has 1 visible message (0 hidden) in 529 octets.
list#列出信件一覽表。

+OK 1 visible messages (529 octets)
1 529
.
retr 1#使用 retr指令來檢視第一封信件的內容。

+OK 529 octets
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from client.paching.idv.tw (client.paching.idv.tw [192.168.1.188])
by mta.paching.idv.tw (Postfix) with SMTP id E8FC5155
for <[email protected]>; Thu, 24 Nov 2005 07:53:30 +0800 (CST)
subject: test
Message-Id: <[email protected]>
Date: Thu, 24 Nov 2005 07:53:30 +0800 (CST)
From: [email protected]
To: undisclosed-recipients:;
X-UIDL: V9+!!7WP!!Pda"!N?L!!

Hello mary, i am barry.
How are you ?

.
dele 1刪除第一封信。
+OK Message 1 has been deleted.
quit退出與 POP3 Server的對話。
+OK Pop server at suse signing off.
Connection closed by foreign host.

您可以配置outlook,來檢驗能否收發郵件

轉載參考:

http://www.suse.url.tw/sles10/lesson17.htm

http://blog.csdn.net/dotuian/article/details/8552418


相關推薦

suse架設postfix郵件伺服器

環境: Suse Linux Enterprise Server 11(x86_64) SP1  Postfix 需要安裝的元件 套 件 名 稱 簡 單 描 述 postfix SMTP Server 的主要套件。 qpopper POP3 Ser

Linux中postfix郵件伺服器的搭建(親測)

 postfix是Wietse Venema在IBM的GPL協議之下開發的MTA(郵件傳輸代理)軟體。postfix是Wietse Venema想要為使用最廣泛的sendmail提供替代品的一個嘗試。在Internet世界中,大部分的電子郵件都是通過sendmail來投遞的,大約有100萬

postfix郵件伺服器的關鍵安全策略

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

centos7搭建postfix郵件伺服器(騰訊雲)

用騰訊雲的先去開啟25埠,在控制檯頁面使用者名稱下面,,,我被坑了好久,,,,   在使用qq等郵件伺服器廠商提供的郵件服務後,發現他們的郵件傳送數量是有限制的,隨著公司的業務的需求下,我們需要搭建一個郵件伺服器,郵件伺服器可以幫助我們在一些提醒方面和訊息推送方面起到幫助。

(RHCE)3 postfix郵件伺服器搭建

在紅帽七中提供的郵件伺服器軟體為postfix ------- 它的配置檔案在/etc/postfix/main.cf 我們通過對它的配置 可以實現郵件伺服器 myhostname=server3.e

Linux總結筆記9-搭建Postfix郵件伺服器

1.修改主機名和部署好DNS伺服器 [[email protected] ~]# hostname mail.kangvcar.com [[email protected] ~]

Postfix郵件伺服器搭建之準備工作

說實話,Postfix郵件伺服器的搭建是一件很麻煩的事情,需要各種軟體之間的配置和除錯。在寫這篇文章之前,我也是搭建測試了不下於10次才算把整個流程給走通,今天剛好有時間把整個搭建過程記錄下來。 在正式安裝postfix之前,我們先來介紹在搭建之前所需要做的準備工作。

使用postfix+dovecot搭建一臺郵件伺服器

一,前期準備 1.各種賬號 *注意:如果是真實環境,使用者名稱密碼等會有複雜度要求,請酌情建立。 不用統一建立這些賬號,後面教程會一一提到 賬號 使用者名稱 密碼 說明 centos r

搭建Postfix-Devocot郵件伺服器詳細步驟

環境準備:CentOS6.5伺服器,安裝了MySQL5.6.23 指令碼準備:系統報警shell指令碼 1.克隆之前安裝好的CentOS系統,注意需要修改網絡卡配置資訊 注意點:(1)修改網絡卡的引數HWaddr為ifconfig -a 出現的一樣(原HWaddr是之前克隆的,沒有更

Redhat配置郵件伺服器postfix+dovecot)

本實驗在redhat虛擬機器中實現:(虛擬機器通過橋接方式連線PC) PC IP:192.168.0.102  閘道器:192.168.0.1(路由器)DNS:192.168.0.1 Redhat IP:192.168.0.105  閘道器:192.168.0.1(路由器

Linux系統下郵件伺服器的搭建(Postfix+Dovecot)

對於網站來說,傳送各種例如註冊通知的郵件是很基本的一個需求,之前我一直用的是騰訊的企業郵箱,感覺挺方便的,直接可以繫結QQ郵箱接收郵件,網站配置一下SMTP也就可以發出郵件。但是在前幾天由於有重要資訊需要立即通知使用者,所以選擇了群發郵件的方式。在當我以為一切都是辣麼完美的時

CentOS利用postfix搭建郵件伺服器

之前我用nodemailer通過163郵箱來發送郵件,不過沒過幾天就一直ETIMEDOUT,不知道什麼原因,想著還是自己搭一個來發郵件可能靠譜點(flag?) 安裝postfix CentOS 7 自帶了postfix服務,在/etc/postfix 目錄下

阿里雲CentOS Linux6.5伺服器上用postfix +dovecot搭建郵件伺服器--親測好用

注:本文的郵件伺服器只用於傳送郵件,也就是STMP伺服器。 企業域名1082.cn 郵件伺服器 mail.1082.cn Mail伺服器名: mail.1082.cn IP:120.24.70.237 一、準備工作 1. 為郵件伺服器新增DNS解析 雖然不加DNS解

記 搭建郵件伺服器(postfix)踩過的坑

首先搭建 postfix 郵件伺服器本身難度不大,主要是當遇到問題了能夠找打解決辦法,有些問題是系統配置問題,你得找到地方修改,再次是有些問題不是那麼明顯的就在終端顯示出來了,你得學會分析日誌,分析日誌的前提是你得知道有對應日誌的存在。先附上鍊接  www.cmhello.

Ubuntu 16.04 佈置postfix、dovecot郵件伺服器

一、引言         postfix是Wietse Venema在IBM的GPL協議之下開發的MTA(郵件傳輸代理)軟體,也就是我們常說的SMTP服務端。postfix是Wietse Venema想要為使用最廣泛的sendmail提供替代品的一個嘗試。它更快、更容易管

郵件伺服器搭建(postfix+dovecot+foxmail)

一、安裝postfix 系統裡一般會有,不用安裝 沒有的(yum install -y postfix) 檢視安裝版本 postconf -d | grep mail_version 二、修改配置檔案 配置檔案 (安裝vim命令不安裝可以使用的vi

在CentOS下用Postfix配置郵件伺服器

在CentOS中,預設的郵件伺服器(SMTP方面)是sendmail,但sendmail有若干的缺點,比如,配置複雜、安全漏洞曾被多次發現- -並且依然存在隱患、郵件傳送速度慢等等,這裡就不再一一敘述。而另一個被廣泛應用於郵件服務方面的“Postfix”的缺點就少得多,或

阿里雲CentOS Linux伺服器上用postfix搭建郵件伺服器

注:本文的郵件伺服器只用於傳送郵件,也就是STMP伺服器。 一、準備工作 1. 為郵件伺服器新增DNS解析 雖然不加DNS解析也能把郵件發出去,但會被大多數郵件伺服器當作垃圾郵件。根據我們的實際經驗,需要新增三條DNS解析記錄:A記錄、MX記錄、TXT記錄。比如域名

Postfix公網郵件伺服器搭建

     在阿里雲上租用一臺雲主機,然後申請一個域名,並在域名記錄中新增MX記錄,mail.youdomain.com記錄。郵箱伺服器必須新增MX記錄,不然在外域向你的郵箱伺服器傳送郵件的時候無法解析到你的郵箱地址,導致被列為垃圾郵件。      首先安裝 postfi

最新ubuntu搭建公網個人郵件伺服器(基於postfix,dovecot,mysql)

  最近做了一個應用,需要用郵件發通知,但是免費的郵箱每天發信數量是有限制的,所以呢就想著搭建一個自己的郵件伺服器,能夠實現郵件的傳送和接收即可,其中大概花了一個星期找資料,測試,終於成功了,寫個教程分享給大家。   本教程基於 ubuntu 18.04(其他的 linux 理論上也是可以的,只是安裝的軟體包