我已经在我的Nginx服务器上尝试了以下内容,但在SSH(或SFTP)login时不会收到任何电子邮件。 我把这个代码放在/etc/rsyslog.d/notify.conf ,并确保这个文件被/etc/rsyslog.conf调用。
$ModLoad ommail $ActionMailSMTPServer example.com $ActionMailFrom [email protected] $ActionMailTo [email protected] $template mailSubject,"User logged into %hostname%" $template mailBody,"RSYSLOG Alert\r\nmsg='%msg%'" $ActionMailSubject mailSubject $ActionExecOnlyOnceEveryInterval 60 if $msg contains 'session opened for user' then :ommail:;mailBody
我也尝试了以下行而不是上面的最后一行:
if $msg contains 'Accepted password for' then :ommail:;mailBody
我已经尝试了上述两种不同情况下的SMTP服务器的主机名变体,其中包括:
hostname.domain.com, 127.0.0.1, [server-ip]
我甚至尝试注释掉整个$ActionMailSMTPServer行。
我不明白为什么rsyslog邮件不工作。 电子邮件通过bash工作得很好(例如mail [email protected] )。 我究竟做错了什么?
除了Exim和Courier外,我还使用了Ubuntu 14.04。