sendmail的基本配置

设置域名解析
---------------------------------------
[root@linux-tys root]# vi /etc/named.conf   
添加内容:
zone "test.com" IN {
        type master;
        file "test.com.zone";
        allow-update { none; };
};
include "/etc/rndc.key";
~
"/etc/named.conf" [已转换] 45L, 850C 已写入 
                                
[root@linux-tys root]# cd /var/named
[root@linux-tys named]# ls
localhost.zone  named.ca  named.local
[root@linux-tys named]# cp localhost.zone  test.com.zone
[root@linux-tys named]# vi test.com.zone
$TTL    86400
$ORIGIN localhost.
test.com.               IN SOA  ns1.test.com.  root.localhost. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
test.com.               IN NS   ns1
[url]www.test.com[/url].           IN A    192.168.0.154
ns1.test.com.           IN CNAME www
test.com.               IN MX   10 mail                        ---建立邮件服务器记录
mail.test.com.          IN A    192.168.0.154

"test.com.zone" [已转换] 14L, 384C 已写入
------------------------------------------------------------------
重启服务
----------------------
[root@linux-tys named]# service named start
[root@linux-tys named]# vi /etc/resolv.conf
search  test.com
nameserver 192.168.0.154
--------------------------------------------------------------------~
测试及其它准备工作
-------------------------------------                             
[root@linux-tys named]# nslookup mail.test.com
Note:  nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead.  Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server:         192.168.0.154
Address:        192.168.0.154#53
Name:   mail.test.com
Address: 192.168.0.154
-----------------------------------------------------------------------
[root@linux-tys named]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=mail.test.com      -----修改邮件服务器名
GATEWAY=192.168.0.1
-----------------------------------------------------------------------~
                         
[root@linux-tys named]# reboot
Last login: Fri May 18 19:31:52 2007 from 192.168.0.16
[root@mail root]# hostname
mail.test.com
[root@mail root]# sendmail -d0 test.com
Version 8.12.8
 Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
                MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
                NETUNIX NEWDB NIS PIPELINING SASL SCANF STARTTLS TCPWRAPPERS
                USERDB USE_LDAP_INIT
============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = mail
  (canonical domain name) $j = mail.test.com
         (subdomain name) $m = test.com
              (node name) $k = mail.test.com
========================================================
sendmail设置
--------------------------------------------
[root@mail root]# vi /etc/mail/sendmail.mc
将DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
修改为dnl DAEMON_OPTIONS(`Port=smtp,Addr=192.168.0.154, Name=MTA')dnl
     
[root@mail root]# cd /etc/mail
[root@mail mail]# cp sendmail.cf sendmail.cf.bak
[root@mail mail]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
[root@mail mail]# cd /var/spool/mqueue
[root@mail mqueue]# mkdir q1 q2 q3 q4 q5
[root@mail mqueue]# vi /etc/xinetd.d/ipop3
# default: off
# description: The POP3 service allows remote users to access their mail \
#              using an POP3 client such as Netscape Communicator, mutt, \
#              or fetchmail.
service pop3
{
        disable = no
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/ipop3d
        log_on_success  += HOST DURATION
        log_on_failure  += HOST
}
           
[root@mail mqueue]# vi /etc/xinetd.d/imap
# default: off
# description: The IMAP service allows remote users to access their mail using \
#              an IMAP client such as Mutt, Pine, fetchmail, or Netscape \
#              Communicator.
service imap
{
        disable = no
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/imapd
        log_on_success  += HOST DURATION
        log_on_failure  += HOST
}
~
~           
[root@mail mqueue]# service xinetd reload
重新载入配置:[  确定  ]
[root@mail mqueue]# service xinetd restart
停止 xinetd:[  确定  ]
启动 xinetd:[  确定  ]
[root@mail mqueue]# service sendmail start
启动 sendmail:[  确定  ]
启动 sm-client:[  确定  ]
[root@mail mqueue]# useradd user1
[root@mail mqueue]# passwd user1
Changing password for user user1.
New password:
BAD PASSWORD: it's WAY too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mail mqueue]# useradd user2
[root@mail mqueue]# useradd user3
You have new mail in /var/spool/mail/root
[root@mail mqueue]# passwd user2
Changing password for user user2.
New password:
BAD PASSWORD: it's WAY too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mail mqueue]# passwd user3
Changing password for user user3.
New password:
BAD PASSWORD: it's WAY too short
Retype new password:
passwd: all authentication tokens updated successfully.
--------------------------------------------------------
测试收发邮件
------------------------
[root@mail mqueue]# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 2 messages 2 new
>N  1 [email protected]  Fri Sep  8 09:29  63/1895  "LogWatch for linux-ty"
 N  2 [email protected]  Fri May 18 19:45 143/4788  "Postmaster notify: se"
& q
Held 2 messages in /var/spool/mail/root
[root@mail mqueue]# mail user1
Subject: halo
this is a test
.
Cc: user2
[root@mail mqueue]# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 2 messages 2 unread
>U  1 [email protected]  Fri Sep  8 09:29  64/1905  "LogWatch for linux-ty"
 U  2 [email protected]  Fri May 18 19:45 144/4798  "Postmaster notify: se"
& q
Held 2 messages in /var/spool/mail/root
[root@mail mqueue]# vi /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
test.com
mail.test.com
~
"/etc/mail/local-host-names" [已转换] 3L, 87C 已写入         
[root@mail mqueue]# chkconfig ipop3 on
[root@mail mqueue]# chkconfig imap on
[root@mail mqueue]# iptables -F
[root@mail mqueue]# service sendmail restart
关闭 sendmail:[  确定  ]
关闭 sm-client:[  确定  ]
启动 sendmail:[  确定  ]
启动 sm-client:[  确定  ]
[root@mail mqueue]# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 2 messages 2 unread
>U  1 [email protected]  Fri Sep  8 09:29  64/1905  "LogWatch for linux-ty"
 U  2 [email protected]  Fri May 18 19:45 144/4798  "Postmaster notify: se"
& q
Held 2 messages in /var/spool/mail/root
---------------------------------------------------------------------------------------
设置有条件转发
-----------------------------------------------
[root@mail mqueue]# vi /etc/mail/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           RELAY
localhost                       RELAY
127.0.0.1                       RELAY
test.com                        RELAY
root@mail mqueue]# cd /etc/mail
[root@mail mail]# echo "192.168.0 RELAY" >> ACCESS     添加允许转发的网络
[root@mail mail]# makemap hash access < access          生成access.db文件
[root@mail mail]# killalll -9 sendmail
-bash: killalll: command not found
[root@mail mail]# killall -9 sendmail
[root@mail mail]# sendmail -bd -q1h                     重启sendmail
[root@mail mail]# service sendmail start
启动 sendmail:
[root@mail mail]# service xinetd restart
停止 xinetd:[  确定  ]
启动 xinetd:[  确定  ]

你可能感兴趣的:(配置,职场,sendmail,邮件服务器,休闲)