sendmail配置

一,安装:
[root@station10 ~]# yum install -y sendmail*

[root@station10 ~]# rpm -aq | grep sendmail
sendmail-doc-8.13.8-2.el5
sendmail-cf-8.13.8-2.el5
sendmail-devel-8.13.8-2.el5
sendmail-8.13.8-2.el5
[root@station10 ~]#

[@more@]


二,sendmail进入的配置
1,修改 /etc/mail/sendmail.mc 文件,让监听所有网卡地址,在前面加上dnl # 即可:

[root@station10 mail]# vi sendmail.mc
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

2,修改 /etc/mail/local-host-names 文件。
[root@station10 mail]# cat local-host-names
# local-host-names - include all aliases for your machine here.
station10.example.com
[root@station10 mail]#

3,重启 sendmail

[root@station10 mail]# service sendmail restart
Shutting down sendmail: [FAILED]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@station10 mail]#

4,查看监听的端口:
[root@station10 ~]# netstat -tulpn | grep sendmail
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1094/sendmail: acce
[root@station10 ~]#


5,测试
[root@station10 ~]# mail -v root
Subject: test mail
test.
.
Cc:
root... Connecting to [127.0.0.1] via relay...
220 station10.example.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 21 Oct 2008 00:13:23 +0800
>>> EHLO station10.example.com
250-station10.example.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<root@station10.example.com> SIZE=35
250 2.1.0 <root@station10.example.com>... Sender ok
>>> RCPT To:<root@station10.example.com>
>>> DATA
250 2.1.5 <root@station10.example.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 m9KGDNiO001110 Message accepted for delivery
root... Sent (m9KGDNiO001110 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 station10.example.com closing connection
[root@station10 ~]#


三,sendmail 出去的配置
1,umcomment the following linex in /etc/mail/sendmail.mc

EXPOSED_USER(`root')dnl
FEATURE(masquerade_envelope)dnl
MASQUERADE_AS('station10.example.com')dnl
FEATURE(masquerade_entire_domain)dnl

2,测试
[root@station10 ~]# mail -v root@station12.example.com
Subject: test
from station10.example.com
.
Cc:
root@station12.example.com... Connecting to [127.0.0.1] via relay...
220 station10.example.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 21 Oct 2008 00:43:26 +0800
>>> EHLO station10.example.com
250-station10.example.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<root@station10.example.com> SIZE=73
250 2.1.0 <root@station10.example.com>... Sender ok
>>> RCPT To:<root@station12.example.com>
>>> DATA
250 2.1.5 <root@station12.example.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 m9KGhQAN001280 Message accepted for delivery
root@station12.example.com... Sent (m9KGhQAN001280 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 station10.example.com closing connection
[root@station10 ~]#

3,在其他机器上接收邮件
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@station10.examp Tue Oct 21 07:56 19/905 "test"
& 1
Message 1:
From root@station10.example.com Tue Oct 21 07:56:06 2008
Date: Tue, 21 Oct 2008 00:43:26 +0800
From: root <root@station10.example.com>
To: root@station12.example.com
Subject: test

from station10.example.com

& q
Saved 1 message in mbox
[root@station12 ~]#


四,进入的邮箱别名
1,本地别名配置:/etc/aliases
[root@station10 mail]# vi /etc/aliases
新增:
xxx: root

xxx这个名字可以是不存在的用户,用户名后面记得加:

2,执行newaliases让配置生效。
[root@station10 ~]# newaliases
/etc/aliases: 77 aliases, longest 10 bytes, 772 bytes total
[root@station10 ~]#

3,测试
[root@station10 ~]# mail xxx
Subject: test inbound
send to xxx
.
Cc:
[root@station10 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@station10.examp Tue Oct 21 00:51 16/659 "test inbound"
& 1
Message 1:
From root@station10.example.com Tue Oct 21 00:51:43 2008
Date: Tue, 21 Oct 2008 00:51:43 +0800
From: root <root@station10.example.com>
To: xxx@station10.example.com
Subject: test inbound

send to xxx

& q
Saved 1 message in mbox
[root@station10 ~]#


4,虚拟别名配置:
修改/etc/mail/virtusertable文件,增加下面一行:
root@station10.example.com root@station12.example.com

[root@station10 mail]# cat virtusertable
root@station10.example.com root@station12.example.com
[root@station10 mail]#

5,重启服务
[root@station10 mail]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@station10 mail]#


6,测试:
发送到station10服务器中:
[root@station10 mail]# mail root@station10.example.com
Subject: test inbound sendmail Aliases
send to station10
.
Cc:
[root@station10 mail]#

在station12服务器中接收到数据:
Saved 1 message in mbox
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@station10.examp Tue Oct 21 08:13 19/921 "test inbound sendmail"
& 1
Message 1:
From root@station10.example.com Tue Oct 21 08:13:36 2008
Date: Tue, 21 Oct 2008 01:00:56 +0800
From: root <root@station10.example.com>
To: root@station10.example.com
Subject: test inbound sendmail Aliases

send to station10

& q
Saved 1 message in mbox
[root@station12 ~]#


五,出去的地址重写
1,在/etc/mail/sendmail.mc中增加如下内容:
FEATURE(genericstable)dnl
FEATURE(`always_add_domain')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/local-host-names')dnl

例子,文件最后几行:
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
FEATURE(genericstable)dnl
FEATURE(`always_add_domain')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/local-host-names')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl

2,新增文件 /etc/mail/genericstable,并添加如下内容:
[root@station10 mail]# cat /etc/mail/genericstable
root@station10.example.com root@redhat.com
tapeback@station10.example.com tapeback.lastname@station10.example.com
[root@station10 mail]#

3,重启服务
[root@station10 mail]# /etc/init.d/sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@station10 mail]#

4,测试:
发送邮件给station12.example.com
[root@station10 ~]# mail root@station12.example.com
Subject: station10.example.com
test
.
Cc:
[root@station10 ~]#

查收接收到邮件:
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 2 messages 2 new
>N 1 logwatch@station10.e Tue Oct 21 11:14 69/2334 "Logwatch for station1"
N 2 root@redhat.com Wed Oct 22 02:39 19/867 "station10.example.com"
& 2
Message 2:
From root@redhat.com Wed Oct 22 02:39:53 2008
Date: Tue, 21 Oct 2008 19:26:56 +0800
From: root <root@redhat.com>
To: root@station12.example.com
Subject: station10.example.com

test

& q
Saved 1 message in mbox
Held 1 message in /var/spool/mail/root
[root@station12 ~]#

六,垃圾邮件限制:
1,enable in /etc/mail/sendmail.mc using
FEATURE('blacklist_recipients')dnl

2, add restrictions in /etc/mail/access

From:90trialspammer@aol.com REJECT
Connect:spamRus.net REJECT
Connect:204.168.23 REJECT
Connect:10.3 OK
From:virtualdomain1.com RELAY
to:user@dom9.com ERROR:550 mail discarded
to:nobody@ ERROR:550 bad name

七,Sendmail Operation

mail -v user
view SMTP exchange with local relay

mailq and mailq -Ac
view messages queued for future delivery

sendmail -q
reprocess the email queue

tail -f /var/log/maillog
view log in real-time

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-1012207/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-1012207/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值