-
安裝 Postfix 套件:
#yum -y install postfix dovecot
-
編修設定檔 /etc/postfix/main.cf:
#vim /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
mynetworks_style = class
mynetworks = 127.0.0.0/8, 192.168.100.0/24
inet_interfaces = all
mydestination = $mydomain, $myhostname, localhost.$mydomain, localhost
mail_spool_directory = /var/mail
home_mailbox = Maildir/
mailbox_size_limit = 0 #原設定參數沒有
message_size_limit = 0 #請自己加上即可
-
編修設定檔 /etc/dovecot/dovecot.conf:
#vim /etc/dovecot/dovecot.conf
protocols = imap pop3
-
編修設定檔 /etc/dovecot/conf.d/10-mail.conf:
#vim /etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u
-
設定防火牆,放行 smtp 與 imap 的服務:
#firewall-cmd --permanent --add-service=smtp
#firewall-cmd --permanent --add-port=110/tcp
#firewall-cmd --permanent --add-port=143/tcp
#firewall-cmd --reload
-
設定 SELinux :
#setsebool -P postfix_local_write_mail_spool on
-
啟動 smtp 與 imap 的服務:
#systemctl enable postfix
#systemctl enable dovecot
#systemctl start postfix
#systemctl start dovecot
-
發送 mail ,檢測服務是否運作正常:
#mail student@mail.example.com
Subject: test
Hello World!
.
-
查看一下 /var/log/maillog 的記錄 :
#tail /var/log/maillog
-
可以利用 mutt 或 thunderbird 來檢測:
#yum -y install thunderbird mutt
mutt 的小設定
#su - student
$vim ~/.muttrc
set mbox_type=Maildir
set folder="~/Maildir"
set mask="!^\\.[^.]"
set mbox="~/Maildir"
set record="+.Sent"
set postponed="+.Drafts"
set spoolfile="~/Maildir"
使用 mutt 來測試:
$mutt