postfix 配置邮件服务器

ⅰ亾dé卋堺 提交于 2019-12-20 03:15:10

准备工作 搭建dns

 --------------------------------------------------------------------------------------------------------------------

配置postfix邮件系统实现收发,,,手机端和web端收发

yum install postfix

vi /etc/postfix/main.cf

 

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.abc.com
mydomain = abc.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost $mydomain
local_recipient_maps =
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Mailbox
home_mailbox = Maildir/


smtpd_banner = $myhostname ESMTP unknow
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
smtp_sasl_auth_enable=yes
smtp_sasl_type=cyrus
smtp_sasl_security_option=noanonymous
broken_sasl_auth_clients=yes
smptd_recipient_restrictions=permit_sasl_authenticated,rejedt_unauth_destination,permit_mynetworks
smtpd_client_restrictions=permit_sasl_authenticated

 

yum install dovecot 

vi /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp
login_trusted_networks =0.0.0.0/0
dict {
}
!include conf.d/*.conf
!include_try local.conf

 

vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir
namespace inbox {
inbox = yes
}
mbox_write_locks = fcntl

 

vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = yes
auth_mechanisms = plain login
!include auth-system.conf.ext

vi /etc/dovecot/conf.d/10-master.conf

service imap-login {
inet_listener imap {
}
inet_listener imaps {
}
}
service pop3-login {
inet_listener pop3 {
}
inet_listener pop3s {
}
}
service lmtp {
unix_listener lmtp {
}
}
service imap {
}
service pop3 {
}
service auth {
unix_listener auth-userdb {
user = postfix
group = postfix
}
}
service auth-worker {
}
service dict {
unix_listener dict {
}
}

 

systemctl restart dovecot

以上可以实现收发

 

同时也可以设置群发

vi /etc/aliases

hhh: aaa bbb


newaliases

这样给hhh发邮件同时aaa和bbb都可以收到邮件

-----------------------------------------------------------------------------------------------------------------------------------------------------

配置手机收发(smtp认证)

yum install cyrus*

systemctl start saslauthd.service

systemctl enable saslauthd.service

postconf -a

vi /etc/sysconfig/saslauthd

MECH=shadow

 

setsebool -P saslauthd_read_shadow on

testsaslauthd -u aaa -p 123

 

----------------------------------------------------------------------------------------------------------------------------------------------------------

配置webmail

依赖安装httpd

yum install httpd

yum install squirrelmail.noarch 

/usr/share/squirrelmail/config/conf.pl   #设置 只要是domain和smtp  也可能有imap

 

vi /etc/httpd/conf/httpd.conf

<Directory />
AllowOverride none
Require all granted
</Directory>

Alias /webmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
Options Indexes FollowSymLinks
RewriteEngine On
AllowOverride All
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>

 

setsebool -P httpd_can_sendmail on

systemctl restart httpd

现在就实现了web,手机,和foxmain  收发邮件了

-------------------------------------------------------------------------------------------------------------------------------------------

配置tls加密

yum install crypto-utils.x86_64 mod_ssl.x86_64 

genkey --days 3650 postfix。com

vi /etc/postfix/main.cf  #加

smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.com.crt
smtpd_tls_key_file = /etc/pki/tls/privte/postfix.com.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_sercurity_level = may
smtpd_tls_protocols = !SSLv2, !SSLv3

 

vi /etc/dovecot/conf.d/10-ssl.conf 

ssl_cert = </etc/pki/tls/certs/postfix.com.crt
ssl_key = </etc/pki/tls/private/postfix.com.key

systemctl restart postfix.service 

systemctl restart dovecot

 

加密就可以了

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!