email - OSSEC 邮件通知发送邮件失败

标签 email error-handling smtp ossec

尝试获取 ossec 功能时出现错误:电子邮件通知。在这种情况下,我使用了我的 Gmail 帐户。我试过这个 tutorial ,
但我无法收到任何电子邮件。我在里面得到了带有警告的错误日志 Mail not accepted by server .它位于 /var/ossec/logs/ossec.log你可以看到下面的日志。

2017/10/06 20:05:18 os_sendmail(1764): WARN: Mail from not accepted by server
2017/10/06 20:05:18 ossec-maild(1223): ERROR: Error Sending email to 74.125.200$
2017/10/06 20:05:58 ossec-syscheckd: INFO: Starting syscheck scan (forwarding d$
2017/10/06 20:05:58 ossec-syscheckd: INFO: Starting syscheck database (pre-scan$
2017/10/06 20:05:58 ossec-syscheckd: INFO: Initializing real time file monitori$

这是我在 ossec.conf 中的电子邮件配置位于 /var/ossec/etc/ossec.conf
 <global>
    <email_notification>yes</email_notification>
    <email_to>myrealemailaccount@gmail.com</email_to>
    <smtp_server>smtp.gmail.com.</smtp_server>
    <email_from>ossecm@gantz-X450CC</email_from>
    <email_maxperhour>20</email_maxperhour>
    <email_from>myrealemailaccount@gmail.com</email_from>
  </global>

我已经填写了我的 <smtp_server>smtp.gmail.com .什么都没有改变。它仍然在我的 ossec.log 收到错误消息

我怎样才能解决这个问题 ?我在 Ubuntu Server: 16.04 上安装此应用程序

最佳答案

我终于得到了解决方案。对于我的情况,我使用了 Postfix将我的帐户 gmail 连接到我的本地主机。如果您有自己的专用电子邮件服务器(例如在您的服务器中),那就太好了,而不是使用 gmail。

  • 确保你已经更新了你的 linux。
    apt-get update
    
  • 通过终端安装 postfix,如果无法安装 postfix,请尝试更改您的存储库位置 /etc/sources.list然后使用 apt-get update 更新您的 linux , 直到您可以运行以下命令
    sudo apt-get install postfix
    

    或者
    sudo apt-get install mailutils
    

    这将安装 Postfix 以及 few other programs needed for
    .之后你会得到选项,选择网站
  • 配置后缀

    搜索 main.cf/etc/postfix/main.cf , 使用 nano 编辑文件.在文件末尾添加此语法。
    relayhost = [smtp.gmail.com]:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_tls_CAfile = /etc/postfix/cacert.pem
    smtp_use_tls = yes
    

    编辑 sasl_passwd/etc/postfix/sasl_passwd , 编辑文件并将以下行添加到 sasl_passwd文件:
    [smtp.gmail.com]:587    your_email_here:your_password here
    

    您应该将您想要作为 ossec 电子邮件通知发件人的电子邮件放在该 `sasl_pawd 上。不作为接收器。
  • 编辑您的 /var/ossec/etc/ossec.conf ,并更改您的 SMTP 以访问本地 ip,如 127.0.0.1localhost
      <global>
       <email_notification>yes</email_notification>
       <email_to>your email that want to be send to</email_to>
       <smtp_server>localhost</smtp_server>
       <email_from>127.0.0.1</email_from> #if 127.0.0.1 didnt work ,try same email address which you put in your sasl passwd 
       <email_maxperhour>100</email_maxperhour>
      </global>
    

  • 2018 年 5 月 22 日更新

    更多配置请阅读this教程和 this

    关于email - OSSEC 邮件通知发送邮件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46585383/

    相关文章:

    mysql - 查询失败,出现以下错误:: (Error #1366) Incorrect integer value: '' for column; how to set version compatibility

    c# - 服务器响应为 : 5. 7.0 必须先发出 STARTTLS 命令。 i16sm1806350pag.18-gsmtp

    python : Sending html format email through SMTP

    multithreading - 无法从 Delphi 中的线程使用 ICS (THtmlSmtpCli) 发送电子邮件

    mysql - 类型错误 : Cannot read property 'filename' of undefined--multer

    email - fosUserBundle 发送邮件注册为空

    python - Python中的空模式未充分利用?

    没有 SMTP 的 JavaMail

    linux - 在 Linux 上使用 sendmail 将邮件消息保存为文件

    c# - 在 Outlook 2010 上访问电子邮件时获取 COMException