未加星标

[原]Linux 下使用sendmail搭建邮件服务器

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏
1、准备email环境 一般采用 yum 安装足够用了,安装命令:

# 安装 sendmail 和配置工具 sendmail-cf

yum install mailx -y yum -y install sendmail

yum install -y sendmail-cf

#SMTP 认证服务

yum install -y saslauthd

安装完后, mail 的日志位置 一般是:/var/log/maillog

测试,有2种方法:

(1)命令行测试:echo "This is test mail" | mail -s 'Test mail aboutsomething else.' [email protected]

(2)文件测试:mail -s "test" [email protected] < /home/email_content.txt

日志调试参考:

调整日志级别(详细程度):修改配置文件define(confLOG_LEVEL',16’)dnl 默认为9 ,或者调用命令时指定sendmail-O LogLevel=14,详细参考: http://www.ibm.com/support/knowledgecenter/zh/ssw_aix_71/com.ibm.aix.networkcomm/sendmail_debugflags.htm

2、报错信息:My unqualified host name (ht_121_90) unknown

这种错误报的比较多,看后台日志,基本信息如下:

Oct 9 14:04:02 localhost sendmail[7902]: restarting /usr/sbin/sendmail due to signal Oct 9 14:04:02 localhost sm-msp-queue[7899]: restarting /usr/sbin/sendmail due to signal Oct 9 14:04:03 localhost sm-msp-queue[8089]: starting daemon (8.14.4): [email protected]:00:00 Oct 9 14:04:03 localhost sendmail[8091]: starting daemon (8.14.4): [email protected]:00:00 Oct 9 14:04:13 localhost sendmail[8123]: starting daemon (8.14.4): [email protected]:00:00 Oct 9 14:04:13 localhost sm-msp-queue[8131]: starting daemon (8.14.4): [email protected]:00:00 Oct 9 14:04:48 localhost sendmail[8200]: My unqualified host name (ht_121_90) unknown; sleeping for retry 分析:

系统sendmail时会把以ht_121_90作为域名加到主机名后组成完整的长名ht_121_90. ht_121_90来访问,系统当然就会报“unabletoqualifymyowndomainname(ht_121_90)”

解决方法:

( 1 )在 vim /etc/mail/sendmail.cf 配置文件中查找 Dj$w, 并在此行下面增加这一行。

Dj$w.

( 2 )在 /etc/hosts 增加一行

[[email protected]_121_90 ~]# more /etc/hosts

127.0.0.1ht_121_90 ht_121_90. #注意后面有一个点.

192.168.121.90 tracker.powerlong.com

[[email protected]_121_90 ~]#

然后重启sendmail服务

[[email protected]_121_90 ~]# service sendmailrestart Shutting down sm-client: [ OK ] Shutting down sendmail: [ OK ] Starting sendmail: [ OK ] Starting sm-client: [ OK ] [[email protected]_121_90 ~]# 再试发送email到qq邮箱,是OK,成功了 [[email protected]_121_90~]# mail -s "test" [email protected] </home/zhanghaoxiang/data-integration/log/job_dw_main.log

You have new mail in /var/spool/mail/root

[[email protected]_121_90 ~]# 查看后台也会显示发送成功了: Oct9 14:14:03 localhost sendmail[8345]: u996E3pw008345:[email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00,mailer=relay, pri=48078, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent(u996E36P008346 Message accepted for delivery) Oct9 14:14:04 localhost sendmail[8348]: STARTTLS=client, relay=mx3.qq.com.,version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128 Oct9 14:14:07 localhost sendmail[8348]: u996E36P008346:to=<[email protected]>, ctladdr=<[email protected]_121_90> (0/0), delay=00:00:04,xdelay=00:00:04, mailer=esmtp, pri=138302, relay=mx3.qq.com. [183.57.48.35],dsn=2.0.0, stat=Sent (Ok: queued as )

^C

3、再报错误DSN: Service unavailable

发送邮件到139邮箱,后台日志报错如下:

Oct 9 14:11:13 localhost sendmail[8330]: u996BDDX008328: to=<[email protected]>, ctladdr=<[email protected]_121_90> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120436, relay=mx1.mail.139.com. [221.176.66.188], dsn=5.0.0, stat=Service unavailable Oct 9 14:11:13 localhost sendmail[8330]: u996BDDX008328: u996BDDX008330: DSN: Service unavailable Oct 9 14:11:13 localhost sendmail[8330]: u996BDDX008330: to=<[email protected]_121_90>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31646, dsn=2.0.0, stat=Sent

解决:

这种一般是网络问题,网络不能访问139的邮件服务器导致,找网络工程师协调查看下服务器的网络配置。

参考文章:

http://blog.csdn.net/enemyisgodlike/article/details/50723866

http://zdm2008.blog.163.com/blog/static/2049154520139795219380/

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: 服务器Linux工程师
分页:12
转载请注明
本文标题:[原]Linux 下使用sendmail搭建邮件服务器
本站链接:http://www.codesec.net/view/480570.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(95)