关于SMTP

今天模考了,话说那个网络真的不好啊,我的25号端口死活ping不通,出了很多问题 ,当时在那个地方整得我心都凉了,这CE还能过不了。回来心情不好,很害怕,这3000块要打水漂?没办法,再研究一下吧,不能就这么放弃了。

可是回到寝室一开VM,不知道咋整的,回来在寝室一ping就通了。后来又看了看官方文档,配好了。呵呵。现在心情还不错。

题目是下面这个:

依下列項目設定您的 SMTP 郵件服務:
- 您的郵件伺服器必須可以接受來自本地端及來自遠端的郵件
- taliesin 必須可以接收來自遠端的郵件
- 寄給 taliesin 的郵件,必須存放在 /var/spool/mail/tailiesin 的郵件佇列


其实说白了就是第一句话了。后面就废话。

#vi /etc/mail/sendmail.mc

看里面注释:

The following causes sendmail to only listen to the IPv4 loopback address 127.0.0.1 and not any other network devices.Remove the loopback address restriction to accept email from the internet or intranet.

意思是说:DAEMON_OPTIONS('Port=smtp,Addr=127.0.0.1,Name=MTA')dnl

这一行里127.0.0.1只能允许本地接收邮件,如果把127.0.0.1这个删掉就能接收来自因特网或者局域网的邮件了。

呵呵。按冲哥说的把127.0.0.1改成0.0.0.0当然是完全可以的。呵呵。

我按注释说的删掉可以吗?试试。。。。。

嗯 ,刚试完,是完全可以的,呵呵。


下面说得详细一点:

自己建的一个server,下面dhcp,DNS服务器全部没有问题,server1.example.com指向server。ip:172.24.254.254

client:ip通过mac绑定为172.24.254.18.hostname:station18.在server1上有DNS指向。


改好client的sendmail配置文件:

#vi /etc/mail/sendmail.mc

可以直接把Addr=127.0.0.1删除

#m4 /etc/mail/sendmail.mc >/etc/mail/sendmail.cf          (这个是最关键的,要不然配置文件不会编译成可用)
#service sendmail restart


切换到server1进行测试:
#mail taliesin@staion18.example.com
#mailq

发现邮件已经出去,队列里面没有

切换到station18,用taliesin login

$mail

看到了发过来的邮件。哈哈。速度很快啊。


最后总结的是,

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

这个一定不能忽略。



附:官方文档里是这么介绍的:
To add the desired functionality to Sendmail, edit the /etc/mail/sendmail.mc file as the root
user. When finished, use the m4 macro processor to generate a new sendmail.cf by executing the
following command:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
By default, the m4 macro processor is installed with Sendmail but is part of the m4 package.
After creating a new /etc/mail/sendmail.cf file, restart Sendmail for the changes to take effect.
The easiest way to do this is to type the following command:
/sbin/service sendmail restart
Important
The default sendmail.cf file does not allow Sendmail to accept network connections
from any host other than the local computer. To configure Sendmail as a server for
other clients, edit the /etc/mail/sendmail.mc file, and either change the address
specified in the Addr= option of the DAEMON_OPTIONS directive from 127.0.0.1 to the
IP address of an active network device or comment out the DAEMON_OPTIONS directive
all together by placing dnl at the beginning of the line. When finished, regenerate /etc/
mail/sendmail.cf by executing the following command:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

The default configuration which ships with Red Hat Enterprise Linux works for most SMTP-only sites.
However, it does not work for UUCP (UNIX to UNIX Copy) sites. If using UUCP mail transfers, the /
etc/mail/sendmail.mc file must be reconfigured and a new /etc/mail/sendmail.cf must be
generated.
Consult the /usr/share/sendmail-cf/README file before editing any files in the directories under
the /usr/share/sendmail-cf directory, as they can affect the future configuration of /etc/mail/
sendmail.cf files.



其实看了官方文档又可以知道,如果不想限制Address的话,直接将DAEMON_OPTIONS一行注释掉就OK了。呵呵。

PS:自己觉得总结经验是一个很好的习惯,以前有个百度博客,总结过很多。总结有一个好处就是可以让新的经验加深印像,

虽然总结的东西不一定以后会常看,但是仔细总结过了自己基本上就全明白了。这就好像一个高手说过的,我也记不得是谁了,他要

将自己的经验写成书出版的话他还要查很多东西 ,因为他也会有些地方不完全透彻,所以完全是不一样的概念。

虽然我不是高手,但是玩linux很长时间了,给一些新手的建义就是学linux要善于总结经验,把你懂的不懂的都记录下来,不懂的再

去花时间弄懂它,这样慢慢积累就会离高手越来越近了。



2009-5-5补充:
However,restarting sendmail will not rebuild sendmail.cf if the sendmail-cf package is not installed.

posted @ 2009-05-02 07:36  冷月X  阅读(213)  评论(0编辑  收藏  举报