歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> RedHat+Postfix+ Cyrus-sasl+ Dovecot+Stunnel

RedHat+Postfix+ Cyrus-sasl+ Dovecot+Stunnel

日期:2017/2/28 16:34:31   编辑:Linux教程

RedHat+Postfix+ Cyrus-sasl+ Dovecot+Stunnel
檢查是否安裝:
rpm -qa | grep postfix
rpm -qa | grep cyrus
rpm –qa | grep dovecot
rpm –qa | grep stunnel
沒有的話,可從系統盤安裝
系統一般都是自動安裝sendmail,所以要先關閉服務或者卸載
/etc/init.d/postfix stop //關閉服務
rpm –e sendmail //卸載
設置關閉sendmail服務
chkconfig sendmail off
開啟Cyrus-sasl,實現密碼驗證
/etc/init.d/saslauthd start
chkconfig saslauthd on
測試:
testsaslauthd –u 用戶名 –p 密碼 提示succcess則表示測試成功
配置SMTP
vi /etc/postfix/main.cf
在文件中編輯以下行
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
header_checks = regexp:/etc/postfix/header_checks
html_directory = no
mailbox_size_limit = 102400000
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man

mydomain = 域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
myhostname = mail.域名
mynetworks = 192.168.1.0/24, 127.0.0.0/8, 192.168.1.100/32
myorigin = $mydomain

newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix-1.1.11/README_FILES
relay_domains = nanoconcept.net
sample_directory = /usr/share/doc/postfix-1.1.11/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
postfix配置文件默認情況下沒有配置SMTP認證機制,所以需要在main.cf添加以下內容來實現SMTP的認證:
smtpd_sasl_auth_enable = yes #該smtp需要用戶認證
smtpd_sasl_local_domain= ''
smtpd_recipient_restrictions = permit_sasl_authenticated permit_auth_destination permit_mynetworks check_relay_domain reject_rbl_client yahoo.com.tw reject_rbl_client cbl.anti-spam.org.cn reject_rbl_client cdl.anti-spam.org.cn reject_rbl_client cblplus.anti-spam.org.cn reject_non_fqdn_sender reject_non_fqdn_recipient reject_unknown_sender_domain reject_unknown_recipient_domain reject

broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options=noanonymous #拒絕所有匿名認證
unknown_local_recipient_reject_code = 550

注:
1)mydomain
指明你的域名:
mydomain = xx.com
2)myorigin
myorigin參數指明發件人所在的域名:
myorigin = $mydomain
3)inet_interfaces
inet_interfaces = all 監聽所有端口
4)mydestination
mydestination參數指定postfix接收郵件時收件人的域名:
mydestination = $mydomain
5)mynetworks_style
設置網絡類型:
mynetworks_style = subnet
6)mynetworks
定義可以使用的此smtp服務器發信的客戶ip地址:
mynetworks = 192.168.1.0/24
注: 也可設置成10.10.1.0~10.10.1.9,10.10.3.0~10.10.3.9

開啟postfix
/etc/init.d/postfix start
Postfix服務一旦成功啟動,可通過netstat –ntl | grep 25查看25端口
chkconfig postfix on
服務開啟成功,即可通過客戶端發送郵件


Pop3服務
Pop3為接受郵件服務,無需特殊需求,不需配置,可直接開啟服務
/etc/init.d/dovecot start
可通過netstat –ntl查看是否開啟端口110

Stunnel功能是實現端口加密,配置文件默認對smtp和pop3端口進行加密,所以無需配置,直接開啟其服務:
/etc/init.d/stunnel start

Copyright © Linux教程網 All Rights Reserved