教你如何在CentOS 5.9系统中安装配置sendmail邮件服务器
sendmail所需包只需两个:
# rpm -qa |grep sendmail
sendmail-8.13.8-2.el5
sendmail-cf-8.13.8-2.el5
安装sendmail做smtp SERVER
步骤一:Sendmail前先做DNS 配置 定义主域名
这一步是配置DNS服务器
# cat /etc/named.conf
zone "mydomain.com" IN {
};
vi /var/named/mydomain.zone $TTL
@
@ IN NS
www IN A 192.168.0.12;
test IN A 192.168.0.12;
ftp IN A 192.168.0.12;
pop3 IN A 192.168.0.12;
smtp IN A 192.168.0.1
步骤二:sendmail.cf修改
必须改成实际域名,否则虽然 linux本地能发mail,但一些客户端(如foxmail)无法通过sendmail发mail
C{w}localhost localdomain
改成
C{w}localhost
=========================================
# SMTP client options
#O ClientPortOptions=Family=inet, Address=0.0.0.0
client address不必改,就保持缺省的#
=========================================
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=0.0.0.0, Name=MTA
Addr只能是0.0.0.0
步骤三:linux smtp服务启动
# /etc/init.d/sendmail restart
Shutting down sendmail: [
Shutting down sm-client: [
Starting sendmail: [
Starting sm-client: [
sendmail daemon启动同时也启动了client
步骤四:email客户端PC配置
1. PC
2. pop3 帐户就是unix 普通用户
pop3 account:mac
pop3 password:xxxxxx
3. foxmail 建立帐户
帐户mac@mydomain.com
SMTP SERVER :smtp.mydomain.com
POP3 SERVER :pop3.mydomain.com
#groupadd mailuser
#useradd -g mailuser mac -s /sbin/nologin
/etc/mail/access不必做任何修改
vi access
localhost.localdomain
localhost
127.0.0.1
mydomain.com
smtp.mydomain.com
192.168.0
删掉了192.168.0
FOXMAIL仍能发mail
本机也能发mail给本机帐户
删掉mydomain.com
删掉smtp.mydomain.com
FOXMAIL仍能发mail
本机也能发mail给本机帐户
总之,/etc/mail/access不必做任何修改
注意修/etc/mail/改access,完后都要做两步:
# makemap hash /etc/mail/access.db < /etc/mail/access
# /etc/init.d/sendmail restart
# cat local-host-names
# local-host-names - include all aliases for your machine here.
FOXMAIL仍能发mail
本机也能发mail给本机帐户
======================================================
直接修改 /etc/mail/sendmail.cf文件来配置sendmail的
mc生成法:配置sendmail.mc文件,生成sendmail.cf
只是在做身份验证的时候才使用sendmail.mc文件
vi /etc/mail/sendmial.mc
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
此时可以在本地给本机发mail
但在其他PC无法用foxmail通过 sendmail发邮件
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=192.168.1.12, Name=MTA
此时linux本地无法通过mail指令发mail给本机用户
但可以在其他PC用foxmail 通过sendmail 发邮件
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=0.0.0.0, Name=MTA
最佳办法
既可以在本地给本机发mail
也可以在PC用foxmail发
能本地发信给本地帐户,但不能通过异地客户端(foxmail)发信的
能通过异地客户端(foxmail)发信的,而不能本地发信给本地帐户
也可能出现foxmail可以发信给SERVER的另一个帐户,实际仍属于server本地发信,但无法发信给一个mail server的帐户
dovecot pop3 imap邮服务
#yum install dovecot
#chkconfig add dovecot
#service dovecot start
# ls /etc/mail
access
access.db
# cat
====================================
# local-host-names - include all aliases for your machine here
# cat trusted-users
====================================
# trusted-users - users that can send mail as others without a warning
# apache, mailman, majordomo, uucp, are good candidates
# cat access
====================================
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
localhost.localdomain
localhost
127.0.0.1
192.168.0
# cat /var/log/maillog
================================== May
May
May