大网数据广告活动
服务器运维问答

monit send email does not work

· 52CE 我爱测

I am trying to use monit, and set up email server using gmail. The configuration file is like this: set mailserver smtp.gmail.com port 587 username "[email omitted]" password "password" using tlsv1 with timeout 30 seconds And I s…

问题原文

原帖链接 · Jiechao Li · CC BY-SA 3.0

I am trying to use monit, and set up email server using gmail. The configuration file is like this:

set mailserver smtp.gmail.com port 587
username "[email omitted]" password "password"
using tlsv1
with timeout 30 seconds

And I set an alert to test:

check file alerttest with path /.nonexistent
alert [email omitted] with reminder on 500 cycles

But when I use monit validate, the error message I got is this:

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

Anyone has any ideas? Thanks a lot

社区高分解答

原帖链接 · David Okwii · CC BY-SA 4.0

You can use a remote mail server. Here are my sample configs which worked. It sends alerts to my gmail through a remote smtp server. I think you still use Gmail as an smtp relay as well.

#configure remote smtp server in monitrc
/etc/monit/monitrc

set mailserver mail.yourmailserver.com port 587    
    username "[email omitted]" password "mypassword"    
    using tlsv1    
    with timeout 30 seconds

#set the from email which should be same as the one above
set mail-format { from: [email omitted] }

//
/etc/monit/conf.d/monit.services

monitor apache2

check process apache with pidfile /var/run/apache2/apache2.pid
       alert [email omitted] 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"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-05-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。