aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/dmarc.lua
diff options
context:
space:
mode:
authorPhil Ross <phil.ross@gmail.com>2019-10-21 19:43:15 +0100
committerPhil Ross <phil.ross@gmail.com>2019-10-23 00:17:05 +0100
commitd80afefcbf9a4afbab4704d9533e7ecb4d85fa3f (patch)
tree38608fc146d2f8136be04ca280b6c1ac09df699e /src/plugins/lua/dmarc.lua
parent0d916d0c7a636fcd72d80f73193d8543a1e6dcd3 (diff)
downloadrspamd-d80afefcbf9a4afbab4704d9533e7ecb4d85fa3f.tar.gz
rspamd-d80afefcbf9a4afbab4704d9533e7ecb4d85fa3f.zip
[Fix] Fix issues sending DMARC reports.
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. Resolves #3054.
Diffstat (limited to 'src/plugins/lua/dmarc.lua')
-rw-r--r--src/plugins/lua/dmarc.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index ab8a3bf53..eab87c85a 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -46,14 +46,14 @@ local report_settings = {
retries = 2,
from_name = 'Rspamd',
}
-local report_template = [[From: "{% from_name %}" <{% from_addr %}>
-To: {% rcpt %}
-Subject: Report Domain: {% reporting_domain %}
- Submitter: {% submitter %}
- Report-ID: {% report_id %}
-Date: {% report_date %}
+local report_template = [[From: "{= from_name =}" <{= from_addr =}>
+To: {= rcpt =}
+Subject: Report Domain: {= reporting_domain =}
+ Submitter: {= submitter =}
+ Report-ID: {= report_id =}
+Date: {= report_date =}
MIME-Version: 1.0
-Message-ID: <{% message_id %}>
+Message-ID: <{= message_id =}>
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_024E_01CC9B0A.AFE54C00"
@@ -63,17 +63,17 @@ This is a multipart message in MIME format.
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
-This is an aggregate report from {% submitter %}.
+This is an aggregate report from {= submitter =}.
-Report domain: {% reporting_domain %}
-Submitter: {% submitter %}
-Report ID: {% report_id %}
+Report domain: {= reporting_domain =}
+Submitter: {= submitter =}
+Report ID: {= report_id =}
------=_NextPart_000_024E_01CC9B0A.AFE54C00
Content-Type: application/gzip
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
- filename="{% submitter %}!{% reporting_domain %}!{% report_start %}!{% report_end %}.xml.gz"
+ filename="{= submitter =}!{= reporting_domain =}!{= report_start =}!{= report_end =}.xml.gz"
]]
local report_footer = [[
@@ -912,6 +912,8 @@ if opts['reporting'] == true then
else
send_report_via_email(xmlf, retry + 1)
end
+ else
+ get_reporting_domain()
end
end
@@ -946,9 +948,9 @@ if opts['reporting'] == true then
report_end = report_end
}, true)
local message = {
- rhead:gsub("\n", "\r\n"),
+ (rhead:gsub("\n", "\r\n")),
encoded,
- report_footer:gsub("\n", "\r\n")
+ (report_footer:gsub("\n", "\r\n"))
}
local lua_smtp = require "lua_smtp"