centos7搭建postfix郵箱

centos7搭建postfix郵件服務器

1. 郵件系統的簡單介紹:

2. 準備環境: 

    2.1 開放端口: 
    firewall-cmd --add-port=25/tcp --permanent

    firewall-cmd –-add-port=110/tcp --permanent

    firewall-cmd --reload

  2.2 移除sendmail

    rpm -e sendmail 或者 yum remove sendmail

  2.3 域名解析配置
我們需要添加A記錄和mx記錄。首先添加A記錄解析到我們的服務器ip。

    2.4 mx 記錄

在需要填入值的地方填入我圖片中的對應字符。

  2.5 修改hostname

    hostnamectl  set-hostname   mail.域名

  2.6 修改MTA(默認郵件傳輸代理)

   alternatives --config mta
然後直接回車即可。

檢查一下是不是已經設置成功了。
    alternatives --display mta
第一行可以看到mta的狀態。 例如:mat - status is manual.就是ok了。

3.POSTFIX
    postfix是提供發件服務的

    postfix服務程序主配置文件中的重要參數。

  3.1 安裝 postfix
在centos7裏我們的postfix是系統自帶的,但是centos7以前的版本是默認不帶的,centos7版本以前是sendmail

如果沒有則安裝 :

yum install postfix
  3.2 配置:
1
vim /etc/postfix/main.cf
修改內容:

myhostname = mail.abc.com

mydomain = abc.com

myorigin = $mydomain

inet_interfaces = all

inet_protocols = ipv4

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mynetworks = 127.0.0.0/8

home_mailbox = Maildir/

smtpd_banner = $myhostname ESMTP

message_size_limit = 10485760

mailbox_size_limit = 1073741824

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
以上對應的對應的行數位置可能隨着版本不同會有差異。具體的一些參數含義在本小節前面有解釋

  3.3 開啓postfix服務並添加到系統自啓。
systemctl restart postfix
systemctl enable postfix

  1. 安裝並配置dovecot
    4.1 安裝dovecot
    yum install dovecot
      4.2 配置dovect
    編輯文件dovecot.conf

vim /etc/dovecot/dovecot.conf
更改內容:

listen = *

login_trusted_networks = 192.168.10.0/24更改內容
編輯文件10-auth.conf

vim /etc/dovecot/conf.d/10-auth.conf
更改內容:

disable_plaintext_auth = no
auth_mechanisms = plain login
編輯文件10-mail.conf

vim /etc/dovecot/conf.d/10-mail.conf
更改內容:

mail_location = maildir:~/Maildir
編輯文件10-master.conf

vim /etc/dovecot/conf.d/10-master.conf
更改內容:

unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
注意:如果我們沒有使用ssl的話需要進行下面的操作。使用了則不需要。

編輯文件10-ssl.conf

vim /etc/dovecot/conf.d/10-ssl.conf
更改內容

ssl = no
啓動dovecot並添加到開機自啓。

systemctl restart dovecot
systemctl enable dovecot
  1. 收發郵件測試  
    5.1 創建用戶
      郵件的用戶是和系統用戶一致的,也就是說系統用戶可以當做郵件用戶。

創建用戶並設置密碼

useradd admin
passwd admin

參考https://www.cnblogs.com/operationhome/p/9056870.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章