Processing the email template was causing a parse error (#3054). This
was caused by the use of `{% ... %}` statements instead of `{= ... =}`
output expressions.
The message was failing to be sent over SMTP, closing the socket after
reading the response to the DATA command and logging the following
errors:
> lua_tcp_arg_toiovec: bad argument at position -1
> lua_tcp_add_write: tcp request has bad data argument at pos 3
This was caused by the number of substitutions made by `gsub` being
added to the message table.
Sending would stop after processing the first message. This was caused
by the sendmail callback function missing a call to
`get_reporting_domain` on a successful outcome.