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][email protected][/email]l  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][email protected][/email]l  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][email protected][/email]l  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:[  確定  ]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章