I'm trying to send email from rsyslog (using the ommail module) on certain events, but no matter what I do the message bodies are always empty.
My configuration file says:
module(load="ommail")
template (name="mailBody" type="string" string="RSYSLOG Alert\\r\\nmsg='%msg%'")
template (name="mailSubject" type="string" string="lti problem on %hostname%")
if $syslogseverity <= 4 and $syslogfacility-text == 'local1' then {
action(type="ommail" server="localhost" port="25"
mailfrom="[email protected]"
mailto="[email protected]"
subject.template="mailSubject")
}
This is copied from the example at https://www.rsyslog.com/doc/v8-stable/configuration/modules/ommail.html
Messages are sent but the body is empty. How do I fix this?
Try this one:
See the
mailBody
template value%msg%
and the parametersbody.enable="on"
andtemplate="mailBody"
.You must specifically set the template on the action clause (with template="mailBody"). This is missing from the example. You may also need body.enable="on" though this is supposedly the default.