Skip to content


sendmail+sasl2创建带smtp的mail server

参考文章

http://www.5dmail.net/html/2007-8-3/20078300406.htm   

使用rhel自带的sendmail和sasl2

修改/etc/mail/local-hosts-name文件

增加本地域和主机的FQDN,记住只是本地主机的FQDN和域名FQDN,不要添加其他域的,否则向外域发送邮件的时候会出现user unknown的错误:

 

[root@localhost named]# vi /etc/mail/local-host-names

 

# local-host-names – include all aliases for your machine here.

 

c1gstudio.com

 

3.更改/etc/mail/sendmail.mc文件,修改下列地方:

 

DaemonPortsOptions=Port=smtp,Addr=127.0.0.1, Name=MTA 更改为:

 

DaemonPortsOptions=Port=smtp,Addr=yourip或者0.0.0.0, Name=MTA

 

然后m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

出现错误

/etc/mail/sendmail.mc:10: m4: Cannot open /usr/share/sendmail-cf/m4/cf.m4:

No such file or directory

在rehat 第四张盘中安装sendmail-cf

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

通过

4.用户管理

 

认证的配置:修改/etc/mail/sendmail.mc中的字段,取消“TRUST_AUTH_MECH”一行和下一行“define”处的注释。(于sendmail.mc文件的第48、49)然后m4 /etc/ mail/sendmail.mc>/etc/mail/sendmail.cf。

 

[root@localhost named]# chkconfig –list saslauthd 开启认证

 

saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

 

[root@localhost named]# chkconfig –level 35 saslauthd on

 

建立用户帐号

 

[root@localhost named]# groupadd mailuser

 

[root@localhost named]# adduser -g mailuser -s /sbin/nologin mike

 

[root@localhost named]# adduser -g mailuser -s /sbin/nologin john

 

[root@localhost named]# passwd mike

 

[root@localhost named]# passwd john 密码都是123

 

设置邮件别名和邮件群发

 

修改/etc/aliases文件实现邮件转发和邮件列表:

 

admin: mike 为邮件用户mike设置别名admin

 

testgroup: mike,john 实现群发 发给testgroup的邮件发给mike 和 john 以上2个可以分别测试

 

#newaliases

5.访问控制设置

 

更改/etc/mail/accesss文件,增加:

 

[root@localhost named]# cat /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

 

c1gstudio.com RELAY

 

完成后makemap hash /etc/mail/access.db < /etc/mail/access进行数据库更新。

6.#service sendmail restart

 

[root@localhost named]# service sendmail restart 启动服务

 

Shutting down sendmail: [FAILED]

 

Starting sendmail: [ OK ]

 

Starting sm-client: [ OK ]

 

[root@localhost named]# telnet localhost 25

 

Trying 127.0.0.1…

 

Connected to localhost.localdomain (127.0.0.1).

 

Escape character is ‘^]’.

 

220 localhost.localdomain ESMTP Sendmail 8.13.1/8.13.1; Sat, 17 Mar 2007 12:54:47 +0800

 

ehlo localhost

 

250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you

 

250-ENHANCEDSTATUSCODES

 

250-PIPELINING

 

250-8BITMIME

 

250-SIZE

 

250-DSN

 

250-ETRN

 

250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN —认证应该生效

 

250-DELIVERBY

 

250 HELP

 

quit

 

221 2.0.0 localhost.localdomain closing connection

 

Connection closed by foreign host.

察看邮件队列内容: 

 

 

mailq 或者 sendmail –bp

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

k7TDIVMI001446      450 Tue Aug 29 21:18 [email protected]

 (Deferred: 451 mta136.mail.cnb.yahoo.com Resources temporaril)

Q-ID:邮件的队列号。Size:邮件的大小。Q-Time:进入队列的时间。Sender/Recipient:发送与接受人的邮箱。


 

察看邮件服务器统计信息:

mailstats

M   msgsfr  bytes_from   msgsto    bytes_to  msgsrej msgsdis  Mailer

 3       41      19626K       67        183K        1       0  local

 4       23         48K      284        321K        1       0  smtp

 5       17         34K       36      19583K        5       0  esmtp

 9      294        479K      134        462K        0       0  procmail

=====================================================

 T      375      20187K      521      20549K        7       0

 C      364                  363                    7

M:是mailer的代号。msgsfr:从此服务器上发出去的邮件。

Msgsfr:代表本服务器发送的邮件数。

Bytes_from:发送出邮件的大小。

Msgsto:收到邮件数。

Bytes_to:首要邮件的大小。

Msgsrej:邮件被deny的次数。

Msgsdis:邮件被discard的次数。

Mailer:sendmail包含的mailer,esmtp主要对外,local主要处理本地的mail。

 

Posted in LINUX, Mail/Postfix, 技术.

Tagged with , , , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.