我正在尝试使用 monit,并使用 gmail 设置电子邮件服务器。配置文件是这样的:
set mailserver smtp.gmail.com port 587
username "someuser@gmail.com" password "password"
using tlsv1
with timeout 30 seconds
Run Code Online (Sandbox Code Playgroud)
我设置了一个警报来测试:
check file alerttest with path /.nonexistent
alert address@gmail.com with reminder on 500 cycles
Run Code Online (Sandbox Code Playgroud)
但是当我使用 monit validate 时,我得到的错误信息是这样的:
Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable
Alert handler failed, retry scheduled for next cycle
'alerttest' file doesn't exist
Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable
'alerttest' trying to restart
Run Code Online (Sandbox Code Playgroud)
任何人有任何想法?非常感谢
您不能配置其他公司的电子邮件服务器来传递电子邮件,除非您在那里拥有实际帐户。即使您确实有一个帐户 monit 也不是处理提交电子邮件的最佳程序。我的建议是安装一个本地 MTA 来监听 127.0.0.1,然后像这样配置 monit:
set mailserver 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
在这种情况下,monit 会将电子邮件交付移交给实际的 MTA,后者可以负责将其发送出去,MTA 完全有能力处理远程服务器不可用的情况,这与 monit 不同(因为它不是为此而设计的)。
如何设置和配置 MTA 超出了本问题的范围,但是如果您希望它直接发送邮件,最好拥有静态 IP、rDNS 和 mx 记录。或者您可以使用远程智能主机/网关。
编辑:简要说明如何安装后缀
跑:
apt-get 安装后缀
选择:
互联网网站
系统邮件名称:
您的系统具有的任何主机名
您现在已将 postfix 配置为向 Internet 发送电子邮件和从 Internet 接收电子邮件。现在,当您如上所述配置 monit 时,您将能够发送电子邮件。
重要的是,为了提高可交付性,您需要确保您的 IP 地址具有解析回您的域的反向 DNS 记录。
例如,如果您的域是 example.org 而您的服务器是 monit.example.org 那么它应该解析如下内容:
host monit.example.org
monit.example.org has address 192.0.43.10
host 192.0.43.10
10.43.0.192.in-addr.arpa domain name pointer monit.example.org
Run Code Online (Sandbox Code Playgroud)
尽管它可以解析为不同的主机名,但只要域相同即可。这是因为许多电子邮件服务器会检查您是否拥有有效的 rDNS。您可以请求您的 ISP(在这种情况下为亚马逊)为您更改 rDNS。
小智 5
您可以使用远程邮件服务器。这是我的示例配置。它通过远程 smtp 服务器向我的 gmail 发送警报。我认为您仍然使用 Gmail 作为 smtp 中继。
#configure remote smtp server in monitrc
/etc/monit/monitrc
set mailserver mail.yourmailserver.com port 587
username "me@yourmailserver.com" password "mypassword"
using tlsv1
with timeout 30 seconds
#set the from email which should be same as the one above
set mail-format { from: me@yourmailserver.com }
//
/etc/monit/conf.d/monit.services
Run Code Online (Sandbox Code Playgroud)
check process apache with pidfile /var/run/apache2/apache2.pid
alert username@gmail.com only on { timeout,nonexist,resource,pid,connection }
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24495 次 |
最近记录: |