• zabbix 基于sendmail发送邮件相关问题


    先看一下脚本

    #!/bin/bash
    to=$1
    subject=$2
    body=$3
    from=3011741665@qq.com
    smtp=smtp.qq.com
    passwd=xxxxxxxxx
    echo `date "+%y-%m-%d %H:%M:%S"` 发送方:$from 接收方:$to 主题:$subject 邮件内容:$body  >>  /tmp/sendmail.log
    /usr/local/bin/sendEmail -v  -f 3011741665@qq.com -t ${to} -s 14.17.57.241 -u ${subject} -o message-content-type=html -o message-charset=utf8 -xu ${from} -xp ${passwd} -m "${body}"   -o tls=auto >> /tmp/sendmail.log 2>&1

     直接通过sendmail命令和脚本执行是没有问题,通过zabbix web界面测试就不行

    查看了sendmail的日志报错是这样的,

    ERROR => Connection attempt to smtp.qq.com:25 failed: IO::Socket::INET: Bad hostname 'smtp.qq.com'
    Nov 19 14:58:07 localhost sendEmail[9777]: Email was sent successfully!  From: <3011741665@qq.com> To: <857510612@qq.com> Subject: [hello zabbix] Server: [smtp.qq.com:25]
    19-11-19 06:59:05 发送方:3011741665@qq.com 接收方:jiyanlong@do1.com.cn 主题:hello zabbix 邮件内容:都是gas的发送到发送到
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: DEBUG => Assigned $opt{} key/value: message-content-type => html
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: DEBUG => Assigned $opt{} key/value: message-charset => utf8
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: DEBUG => Assigned $opt{} key/value: tls => auto
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: DEBUG => Connecting to smtp.qq.com:25
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: ERROR => Connection attempt to smtp.qq.com:25 failed: IO::Socket::INET: Bad hostname 'smtp.qq.com'
    Nov 19 06:59:05 vm_2_9_centos sendEmail[9935]: HINT => Try specifying a different mail relay with the -s option.
    19-11-19 07:00:52 发送方:3011741665@qq.com 接收方:857510612@qq.com 主题:Test subject 邮件内容:This is the test message from Zabbix
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: DEBUG => Assigned $opt{} key/value: message-content-type => html
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: DEBUG => Assigned $opt{} key/value: message-charset => utf8
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: DEBUG => Assigned $opt{} key/value: tls => auto
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: DEBUG => Connecting to smtp.qq.com:25
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: ERROR => Connection attempt to smtp.qq.com:25 failed: IO::Socket::INET: Bad hostname 'smtp.qq.com'
    Nov 19 07:00:52 vm_2_9_centos sendEmail[10222]: HINT => Try specifying a different mail relay with the -s option.

     这里google里好多, 修改了dns,改了hosts解析

     都不行, 最后我把脚本里的smtp.qq.com改为用dig解析的ip,在测试就没有问题了,记录一下;

  • 相关阅读:
    Minecraft我的世界如何联机
    关于我的博客地址jvav的由来
    ThreadLocal使用
    使用免费tk域名
    MVC的request,response流程
    TiDB原理与集群架构
    net5 自定义 中间件
    net5 Autofac支持
    net5 Autofac 支持AOP (1)
    mysql 索引优化
  • 原文地址:https://www.cnblogs.com/52py/p/11889660.html
Copyright © 2020-2023  润新知