QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 802|回复: 4

我建立Mail Server的经历。

[复制链接]
发表于 2003-3-16 16:02:19 | 显示全部楼层 |阅读模式
那天弄完Apache和PHP的事后,休息了两天(其中经历了DNS风波,不过主要是另外一个人的事,因为这两天我都在忙着在公社灌水。

今天下班回来,看看时间还早,才10点多,于是把mail server给搭了起来。在寻找资料的过程中,主要是依靠网上各处的文章慢慢修改的,有多余或错误之处还请大家指正。

[code:1]redhat8默认安装的是sendmail8.12.5.  
设置你的nds server,例如ns1.yourssl.com
添加一条MX纪录@ IN MX 10 ns1.yourssl.com.

安装完系统后,我通过x-windowns看到系统设置--mail transport agent switcher,默认是postfix,我选着了sendmail作为邮件传输代理。
开始安装:
一、首先,要生成sendmail.cf文件,一般是编译sendmail.mc来生成sendmail.cf,这样的好处是通过编译,会查看出一些sendmail的设置错误和漏洞。
# cd /etc/mail
# vi sendmail.mc
divert(-1)
dnl This is the sendmail macro config file. If you make changes to this file,
dnl you need the sendmail-cf rpm installed and then have to generate a
dnl new /etc/mail/sendmail.cf by running the following command:
dnl
dnl m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')
VERSIONID(`linux setup for Red Hat Linux')dnl
OSTYPE(`linux')
dnl Uncomment and edit the following line if your mail needs to be sent out
dnl through an external mail server:
dnl define(`SMART_HOST',`smtp.your.provider')
define(`confDEF_USER_ID',``8:12'')dnl
undefine(`UUCP_RELAY')dnl
undefine(`BITNET_RELAY')dnl
dnl define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
dnl define(`STATUS_FILE', `/etc/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
DAEMON_OPTIONS(`Port=25,Name=MTA')dnl
DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl
dnl define(`confCACERT_PATH',`/usr/share/ssl/certs')
dnl define(`confCACERT',`/usr/share/ssl/certs/ca-bundle.crt')
dnl define(`confSERVER_CERT',`/usr/share/ssl/certs/sendmail.pem')
dnl define(`confSERVER_KEY',`/usr/share/ssl/certs/sendmail.pem')
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
define(`confTO_IDENT', `0')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
dnl The '-t' option will retry delivery if e.g. the user runs over his quota.
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
dnl NOTE: binding both IPv4 and IPv6 daemon to the same port requires
dnl a kernel patch
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not have 24x7 DNS do need this.
dnl FEATURE(`accept_unresolvable_domains')dnl
dnl FEATURE(`relay_based_on_MX')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
Cwlocalhost.localdomain
我根据资料修改了几个地方,其中:
1、2是我打开注解的,是打开相应的认证机制,主要是为了支持outlook
3、4是我添加的,设置相应的mta and msa的所用端口。
5、6要注掉。
1、TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
2、define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
3、DAEMON_OPTIONS(`Port=25,Name=MTA')dnl
4、DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl
5、dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
6、dnl FEATURE(`accept_unresolvable_domains')dnl
最后保存。
二、编译sendmail.mc 生成sendmail.cf文件
# m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
#/etc/rc.d/init.d/sendmail restart --重起sendmail服务。
三、检测编译结果。
1、检测SASL被编译到sendmail中。
#/usr/sbin/sendmail -d0.1 -bv root |grep SASL
输出类似如下:
NETUNIX NEWDB NIS PIPELINING SASL SCANF STARTTLS TCPWRAPPERS
保证你看到SASL就是正确的。
2、检测25端口:
# telnet localhost 25
Trying 127.0.0.1.....
Connected to localhost (127.0.0.1).
Escape character is '^]'.
220 ns1.yourssl.com ESMTP SENDMAIL 8.12.5/8.12.5;THU,13 FEB 2003.19:12:59 +0800
EHLO localhost --打个招呼
250-ns1.yourssl.com hello localhost [127.0.0.1],pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH GSSAPI LOGIN PLAIN
250-DELIVERBY
250-HELP
quit ---退出
只要输出有LOGIN PLAIN就OK!了,不然,就不能relay mail.
到这里,sendmail就配置完了,你可以加一个用户试试看。
邮件用户是系统用户.
#useradd -d /home yangminghao
#passwd yangminghao ----设置密码

四、pop3安装。
redhat8.0中有它的rpm包,是imap-2001a.15.rpm
# rpm -ivh imap-2001a.rpm
#/etc/xinetd.d/ipop3 --这步我没通过,不知道为什么
#/etc/rc.d/init.d/xinetd restart --重起pop3服务
#telnet localhost 110
Trying 127.0.0.1...
Connected to localhost (127.0.0.1)
Escape character is '^]'
+OK POP3 localhost v2001.78rh server ready
quit ---退出
有以上显示,为正确。

目前收信,发信和回复都没问题,还有什么缺陷待以后再弄了。[/code:1]
发表于 2003-3-16 20:24:46 | 显示全部楼层
能否把你配置DNS和APACHE的具体过程告诉小弟我啊!
我也在搞这些东西啊!(email:[email protected]
回复

使用道具 举报

 楼主| 发表于 2003-3-16 23:55:38 | 显示全部楼层
配置Apache的经历已在本版贴出了, 你自己可以看一下。至于DNS,正如象我上面说的那样, 不是我弄的。
回复

使用道具 举报

发表于 2003-3-17 02:41:28 | 显示全部楼层
DNS加入MX记录就行,例子看我的吧!
http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=13333&highlight=
(王婆卖瓜!
回复

使用道具 举报

发表于 2003-3-21 17:02:46 | 显示全部楼层
请问这样的mail服务器是不是太简单了点,你能做到备份发出去的邮件吗?我就差这一步了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-17 06:33 , Processed in 0.062951 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表