码迷,mamicode.com
首页 > 其他好文 > 详细

OTRS工单管理系统安装配置Sendmail

时间:2019-05-13 22:45:42      阅读:497      评论:0      收藏:0      [点我收藏+]

标签:sha   安装与配置   nav   add   文件   sms   别名   vim   set   

(一)、环境
系统:CentOS7.4
Sendmail安装
OTRS:6.0.18

(二)sendmail安装与配置
sendmail是linux系统中一个邮箱系统,如果我们在系统中配置好sendmail就可以直接使用它来发送邮箱。
sendmail的配置文件:
/etc/mail/sendmail.cf :Sendmail的主配置文件;
/etc/mail/access :中继访问控制;
/etc/mail/domaintable ;域名映射;
/etc/mail/local-host-names ;本地主机别名;
/etc/mail/mailertable :为特定的域指定特殊的路由规则;
/etc/mail/virtusertable :虚拟域配置。
中继的配置
是指一台服务器接受并传递源地址和目的地址都不是本服务器的邮件。
在两个文件中进行设置:
/etc/mail/relay-domains
/etc/mail/access

1、sendmail安装

yum install -y sendmail
yum install -y sendmail-cf

2、创建自定义服务启动。

systemctl enable sendmail
systemctl enable sendmail

3、sendmail配置SMTP认证
将下面两行内容前面的dnl去掉。在sendmail文件中,dnl表示该行为注释行,是无效的,因此通过去除行首的dnl字符串可以开启相应的设置行。
先备份在编辑

 cp /etc/mail/sendmail.rc /etc/mail/sendmail.rc.bak
vim /etc/mail/sendmail.mc
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN‘)dnl
define(`confAUTH_MECHANISMS‘, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN‘)dnl

4、设置Sendmail服务的网络访问权限(如果是直接本机调用,可以不用操作,采用默认的127.0.0.1。不过最后还是改成0.0.0.0)
将127.0.0.1改为0.0.0.0,意思是任何主机都可以访问Sendmail服务。
如果仅让某一个网段能够访问到Sendmail服务,将127.0.0.1改为形如192.168.1.0/24的一个特定网段地址。

[root@otrs ~]# vim /etc/mail/sendmail.mc
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA‘)dnl

5、生成配置文件
Sendmail的配置文件由m4来生成,m4工具在sendmail-cf包中。如果系统无法识别m4命令,说明sendmail-cf软件包没有安装
[root@otrs ~]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
6、重启服务
systemctl restart sendmail

7、查看日志和队列

[root@otrs ~]# mailq
/var/spool/mqueue is empty
        Total requests: 0
[root@otrs ~]# tail -f /var/log/maillog
May 13 21:12:06 otrs sendmail[2891]: x4DDC4w2002889: to=<songyaqi@kjdow.com>, delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120993, relay=mxbiz1.qq.com. [183.57.48.34], dsn=5.0.0, stat=Service unavailable
May 13 21:12:06 otrs sendmail[2891]: x4DDC4w2002889: x4DDC6w2002891: DSN: Service unavailable
May 13 21:12:07 otrs sendmail[2891]: STARTTLS=client, relay=mxbiz2.qq.com., version=TLSv1/SSLv3, verify=FAIL, cipher=AES128-SHA256, bits=128/128
May 13 21:12:08 otrs sendmail[2891]: x4DDC6w2002891: to=<otrs@kjdow.com>, delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=32188, relay=mxbiz2.qq.com. [183.57.48.34], dsn=5.0.0, stat=Service unavailable
May 13 21:12:08 otrs sendmail[2891]: x4DDC6w2002891: x4DDC6w3002891: return to sender: Service unavailable
May 13 21:12:08 otrs sendmail[2891]: x4DDC6w3002891: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=33212, dsn=2.0.0, stat=Sent
May 13 21:36:23 otrs sendmail[3202]: starting daemon (8.14.7): SMTP+queueing@01:00:00
May 13 21:36:23 otrs sm-msp-queue[3219]: starting daemon (8.14.7): queueing@01:00:00
May 13 21:43:28 otrs sendmail[3483]: starting daemon (8.14.7): SMTP+queueing@01:00:00
May 13 21:43:28 otrs sm-msp-queue[3500]: starting daemon (8.14.7): queueing@01:00:00

(三)、测试发送邮箱

方法一:安装mailx
[root@otrs ~]#yum -y install mailx
创建一个邮件内容文件,然后发邮件(注意-s参数后的邮件标题要用单引号,不能使用双引号,否则发邮件会失败!)

[root@otrs ~]# echo ‘This is test mail‘>/root/content.txt 
[root@otrs ~]#  cat /root/content.txt
This is test mail
[root@otrs ~]# mail -s ‘this is otrs test message‘ 284315732@qq.com < /root/content.txt 

见下图。
技术图片

也可以通过管道符直接发送邮件内容
[root@otrs ~]# echo "this is first test message of otrs" | mail -s ‘orts-otrs‘ 284315732@qq.com
技术图片

至此sendmail安装配置完成。

方法二:通过外部的smtp服务器进行发送,修改/etc/mail.rc文件,在最下边添加如下配置。上面第一种方式中,/bin/mail命令会默认使用本地sendmail发送邮件,这样要求本地的机器必须安装和启动Sendmail服务,配置非常麻烦,而且会带来不必要的资源占用。
而通过修改配置文件可以使用外部SMTP服务器,可以达到不使用sendmail而用外部的smtp服务器发送邮件的目的。

[root@otrs ~]# cat  /etc/mail.rc
set from=otrs@kjdow.com 
set smtp=smtp.exmail.qq.com  
set smtp-auth-user=otrs@qq.com
set smtp-auth-password=xxxx 
set smtp-auth=login

备注如果sendmail出现 DSN: Service unavailable。这是由于主机名没有正确解析导致的。具体解决步骤如下:

1、cat /etc/hosts
[root@otrs ~]# cat /etc/hosts
183.57.48.34     mxbiz1.qq.com.
192.168.4.203   otrs.bakheet.cn.

2、cat /etc/sysconfig/network
[root@otrs ~]#  cat /etc/sysconfig/network
HOSTNAME=otrs.bakheet.cn
3、重启服务
注意/etc/hosts文件和/etc/sysconfig/network 里面的HOSTNAME必须一致,

并且修改/etc/sysconfig/network里面的hostname文件,必须用命令hostname xxx使其生效,

否则会提示 dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

OTRS工单管理系统安装配置Sendmail

标签:sha   安装与配置   nav   add   文件   sms   别名   vim   set   

原文地址:https://blog.51cto.com/liqingbiao/2394034

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!