linux-sendmail轉發

火星人 @ 2014-03-08 , reply:0


不同地方使用sendmail實現mail的收發


BJ-mail伺服器的配置

1.安裝dns

1.1 安裝包

[root@mail ~]# yum install bind

[root@mail ~]# yum install bind-chroot –改變dns的路徑,保證安全的包

[root@mail ~]# yum install caching-nameserver –y –生成配置文件,提高caching server

[root@mail ~]# yum list all |grep bind

This system is not registered with RHN.

RHN support will be disabled.

bind.i386 30:9.3.4-10.P1.el5 installed

bind-chroot.i386 30:9.3.4-10.P1.el5 installed

bind-libs.i386 30:9.3.4-10.P1.el5 installed

bind-utils.i386 30:9.3.4-10.P1.el5 installed

ypbind.i386 3:1.19-11.el5 installed

1.2 配置

[root@mail ~]# cd /var/named/chroot/etc

[root@mail etc]# cp -p named.caching-nameserver.conf named.conf

[root@mail etc]# vim named.conf

options {

listen-on port 53 { any; };

forwarders { 192.168.101.71;}; --不同區域dns需要轉發

allow-query { any; };

};

view localhost_resolver {

match-clients { any; };

match-destinations { any; };

include "/etc/named.rfc1912.zones";

};

1.3聲明區域

[root@mail ~]# vim /var/named/chroot/etc/named.rfc1912.zones

zone "bj.com" IN {

type master;

file "bj.com.db";

allow-update { none; };

};

zone "101.168.192.in-addr.arpa" IN {

type master;

file "192.168.101.70.db";

allow-update { none; };

};

1.4產生資料庫文件

[root@mail named]# cp -p localhost.zone bj.com.db

[root@mail named]# vim bj.com.db

$TTL 86400

@ IN SOA ns.bj.com. root.126.com (

42 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

IN NS ns.bj.com.

ns IN A 192.168.101.70

mail IN A 192.168.101.70

pop3 IN CNAME mail

smtp IN CNAME mail

imtp IN CNAME mail

@ IN MX 10 mail

[root@mail ~]# vim /var/named/chroot/var/named/192.168.101.70.db

$TTL 86400

@ IN SOA localhost. root.localhost. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

IN NS localhost.

71 IN PTR mail.sh.com.

70 IN PTR mail.bj.com.

1.5 dns指向

[root@mail etc]# vim /etc/resolv.conf

nameserver 192.168.101.70

[root@mail named]# vim /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=mail.bj.com

[root@mail etc]# vim /etc/hosts

127.0.0.1 localhost.localdomain localhost

192.168.101.70 mail.bj.com

--更改主機名

1.6 開啟服務 解析

[root@mail named]# service named start

[root@mail named]# chkconfig named on

[root@mail named]# rndc reload

server reload successful

[root@mail etc]# nslookup mail.bj.com

[root@mail etc]# dig -t mx bj.com

2.Sendmail 需要的包

2.1需要安裝的包

Sendmail-8.13.8.-2.el5 –主包

Sendmai-cf --生成易配置或快速配置的配置文件

Sendmail-devel --開發包

m4.i386 1.4.5-3.el5.1 --轉換工具

--重啟m4會自動轉換

--sendmail.mc—>sendmail.cf

-- accessaccess.db

[root@mail ~]# yum list all |grep sendmail

This system is not registered with RHN.

RHN support will be disabled.

sendmail.i386 8.13.8-2.el5 installed

sendmail-cf.i386 8.13.8-2.el5 installed

sendmail-devel.i386 8.13.8-2.el5 installed

sendmail-doc.i386 8.13.8-2.el5 installed

[root@mail ~]# yum list all |grep m4

This system is not registered with RHN.

RHN support will be disabled.

m4.i386 1.4.5-3.el5.1 installed

[root@mail ~]#

2.2配置監聽

更改sendmail.mc

[root@mail mail]# pwd

/etc/mail

[root@mail mail]# vim sendmail.mc

116 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

--默認是本機監聽25號埠,需要更改才能使非本地用戶使用sendmail發送郵件

--Dnl # 是注視文字

--Dnl 是打開可以使用的

--末尾dnl 去除空格

[root@mail mail]# service sendmail restart

[root@mail mail]# netstat -tunpl |grep 25

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 30569/sendmail: acc

2.3.本地認證 --中繼文件

[root@mail ~]# cd /etc/mail

[root@mail mail]# vim access

Connect:localhost.localdomain RELAY

Connect:localhost RELAY

Connect:127.0.0.1 RELAY

#connect:192.168.101. RELAY

-- ok 無條件接受, relay 中繼, reject是拒絕

[root@mail mail]# service sendmail restart

2.4本地域名

--知道自己負責的域增加網段可以發送

[root@mail mail]# vim /etc/mail/local-host-names

mail.bj.com –主機名

bj.com –本地域名

[root@mail mail]# service sendmail restart

2.5 添加本地用戶

[root@mail etc]# useradd user1

[root@mail etc]# useradd user2

[root@mail etc]# passwd user1

[root@mail etc]# passwd user2

3.安裝MAA

[root@mail ~]# yum install dovecot

--更改配置文件

[root@mail ~]# vim /etc/dovecot.conf

20 #protocols = imap imaps pop3 pop3s

--默認全開

22 protocols = pop3

[root@mail ~]# service dovecot restart

[root@mail ~]# chkconfig dovecot on

Sh-mail伺服器的配置

1.dns配置

1.1克隆出現的沒有ip問題

[root@mail network-scripts]# cd /etc/sysconfig/network-scripts/

[root@mail network-scripts]# ll ifcfg*

-rw-r--r-- 1 root root 117 Sep 15 17:20 ifcfg-eth0

-rw-r--r-- 1 root root 211 Sep 4 20:39 ifcfg-eth0.bak

[root@mail network-scripts]# mv ifcfg-eth0.bak ifcfg-eth0

mv: overwrite `ifcfg-eth0'? y

[root@mail network-scripts]#

1.2 更改配置

[root@mail etc]# cd /var/named/chroot/etc

[root@mail etc]# vim named.conf

options {

listen-on port 53 { any; };

forwarders { 192.168.101.70;}; --不同區域dns需要轉發

allow-query { any; };

};

view localhost_resolver {

match-clients { any; };

match-destinations { any; };

recursion yes;

include "/etc/named.rfc1912.zones";

};

[root@mail ~]#vim /var/named/chroot/etc/named.rfc1912.zones

zone "sh.com" IN {

type master;

file "sh.com.db";

allow-update { none; };

};

zone "101.168.192.in-addr.arpa" IN {

type master;

file "192.168.101.71.db";

allow-update { none; };

};

--做反向區域,解決不信任,延遲發送郵件的問題

1.3產生資料庫文件

[root@mail etc]# cd /var/named/chroot/var/named

[root@mail named]# mv bj.com.db sh.com.db

[root@mail named]# vim sh.com.db

$TTL 86400

@ IN SOA ns.sh.com. root.126.com (

43 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

@ IN NS ns.sh.com.

ns IN A 192.168.101.71

mail IN A 192.168.101.71

pop3 IN CNAME mail

smtp IN CNAME mail

#imtp IN CNAME mail

@ IN MX 10 mail

[root@mail ~]# cat /var/named/chroot/var/named/192.168.101.71.db

$TTL 86400

@ IN SOA localhost. root.localhost. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

IN NS localhost.

71 IN PTR mail.sh.com.

70 IN PTR mail.bj.com.

[root@mail ~]#

1.4更改主機名

[root@mail named]# vim /etc/resolv.conf

nameserver 192.168.101.71

[root@mail named]# vim /etc/sysconfig/network

HOSTNAME=mail.sh.com

[root@mail named]# vim /etc/hosts

127.0.0.1 localhost.localdomain localhost

192.168.101.71 mail.sh.com

1.5 測試解析域名

[root@mail named]# dig -t mx sh.com

[root@mail named]#

1.6添加用戶

[root@mail ~]# useradd user5

[root@mail ~]# passwd user5

[root@mail ~]# useradd user6

[root@mail ~]# passwd user6

2.sendmail的安裝配置

2.1安裝sendmail

安裝同bj-mail

2.1修改配置文件

[root@mail ~]# mailq

/var/spool/mqueue (6 requests)

-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------

p8FA52pO004641 2 Thu Sep 15 18:05 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user6@mail.bj.com>

p8F9tad9004449 3 Thu Sep 15 17:55 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user5@mail.bj.com>

p8F9sat7004396 3 Thu Sep 15 17:54 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user5@mail.bj.com>

p8F9qa7g004283 3 Thu Sep 15 17:52 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user5@mail.bj.com>

p8F9ldpj004065 3 Thu Sep 15 17:47 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user2@mail.bj.com>

p8F9lmPS004068 3 Thu Sep 15 17:47 <root@mail.bj.com>

(host map: lookup (mail.bj.com): deferred)

<user3@mail.bj.com>

Total requests: 6

--更改配置之前發送給外地區域的郵件都被deferred

[root@mail mail]# vim sendmail.mc

116 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

--默認是本機監聽25號埠,需要更改才能使非本地用戶使用sendmail發送郵件

--Dnl # 是注視文字

--Dnl 是打開可以使用的

--末尾dnl 去除空格

[root@mail ~]# vim /etc/mail/access

Connect:localhost.localdomain RELAY

Connect:localhost RELAY

Connect:127.0.0.1 RELAY

Connect:192.168.101. RELAY

sh.com ok

bj.com RELAY

[root@mail mail]# vim local-host-names

mail.sh.com –主機名

sh.com –本地域名

[root@mail mail]# service sendmail restart

[root@mail mail]# mailq

/var/spool/mqueue is empty

Total requests: 0

對發 bj地方給sh地方發送郵件,對方能接收

[root@mail ~]# netstat -tupln |grep -E "name|dov|send"

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 192.168.101.70:53 0.0.0.0:* LISTEN 2749/named

tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 2749/named

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 5328/sendmail: acce

tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 2749/named

tcp 0 0 :::110 :::* LISTEN 3058/dovecot

tcp 0 0 ::1:53 :::* LISTEN 2749/named

tcp 0 0 ::1:953 :::* LISTEN 2749/named

udp 0 0 0.0.0.0:46353 0.0.0.0:* 2749/named

udp 0 0 192.168.101.70:53 0.0.0.0:* 2749/named

udp 0 0 127.0.0.1:53 0.0.0.0:* 2749/named

udp 0 0 ::1:53 :::* 2749/named

udp 0 0 :::49657 :::* 2749/named

--確保各服務都已經開啟 實現對發

[root@mail ~]# hostname

mail.bj.com

[root@mail ~]# mail user5@sh.com

Subject: hello sh

this is bj.

.

Cc:

[root@mail ~]#

[root@mail ~]# hostname

mail.sh.com

[root@mail ~]# su - user5

[user5@mail ~]$ mail

Mail version 8.1 6/6/93. Type ? for help.

"/var/spool/mail/user5": 2 messages 1 new

1 MAILER-DAEMON@mail.s Fri Sep 16 01:21 13/542 "DON'T DELETE THIS MES"

>N 2 root@mail.bj.com Fri Sep 16 03:28 19/740 "hello sh"

& 2

Message 2:

From root@mail.bj.com Fri Sep 16 03:28:06 2011

Date: Fri, 16 Sep 2011 05:51:57 0800

From: root <root@mail.bj.com>

To: user5@sh.com

Subject: hello sh

this is bj.

&

客戶端使用sendmail發送接收mail

1.配置outlook


使用Outlook給外地發信


本文出自 「一抹茶色陽光」 博客,請務必保留此出處http://sweetsingle.blog.51cto.com/3429592/741829





[火星人 via ] linux-sendmail轉發已經有183次圍觀

http://www.coctec.com/docs/linux/show-post-46677.html