fix(smtp): add missing headers to prevent spam classification
Add required SMTP headers to fix spam classification issues: - Message-ID: generated from timestamp and from_address domain - MIME-Version: 1.0 header for proper email formatting - Content-Transfer-Encoding: 8bit for UTF-8 content Fixes rspamd spam score from 10.42/10.00 (reject) to 4.80/10.00 (clean) by resolving MISSING_MID (-2.50), MISSING_MIME_VERSION (-2.00), and R_BAD_CTE_7BIT (-1.05) penalties. Tested with mail-tester.com (10/10 score) and production deployment on tiamat shows successful delivery to inbox instead of spam folder. Related DAW/infrastruktur#35
This commit is contained in:
parent
4af068e15c
commit
f20915ff33
1 changed files with 11 additions and 2 deletions
13
src/smtp.lua
13
src/smtp.lua
|
|
@ -1,6 +1,6 @@
|
||||||
-- furt-lua/src/smtp.lua
|
-- src/smtp.lua
|
||||||
-- Universal SMTP implementation with SSL compatibility
|
-- Universal SMTP implementation with SSL compatibility
|
||||||
-- Supports both luaossl (Arch/karl) and luasec (OpenBSD/walter)
|
-- Supports both luaossl (Arch) and luasec (OpenBSD)
|
||||||
-- Dragons@Work Digital Sovereignty Project
|
-- Dragons@Work Digital Sovereignty Project
|
||||||
|
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
|
@ -304,6 +304,11 @@ function SMTP:send_email(to_address, subject, message, from_name)
|
||||||
return cleanup_and_fail("DATA command failed: " .. response)
|
return cleanup_and_fail("DATA command failed: " .. response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Generate unique Message-ID
|
||||||
|
-- Extract domain from configured from_address
|
||||||
|
local hostname = self.from_address:match("@(.+)") or self.server
|
||||||
|
local message_id = string.format("<%d.%d@%s>", os.time(), math.random(10000), hostname)
|
||||||
|
|
||||||
-- Build email message
|
-- Build email message
|
||||||
local display_name = from_name or "Furt Contact Form"
|
local display_name = from_name or "Furt Contact Form"
|
||||||
local email_content = string.format(
|
local email_content = string.format(
|
||||||
|
|
@ -311,7 +316,10 @@ function SMTP:send_email(to_address, subject, message, from_name)
|
||||||
"To: <%s>\r\n" ..
|
"To: <%s>\r\n" ..
|
||||||
"Subject: %s\r\n" ..
|
"Subject: %s\r\n" ..
|
||||||
"Date: %s\r\n" ..
|
"Date: %s\r\n" ..
|
||||||
|
"Message-ID: %s\r\n" ..
|
||||||
|
"MIME-Version: 1.0\r\n" ..
|
||||||
"Content-Type: text/plain; charset=UTF-8\r\n" ..
|
"Content-Type: text/plain; charset=UTF-8\r\n" ..
|
||||||
|
"Content-Transfer-Encoding: 8bit\r\n" ..
|
||||||
"\r\n" ..
|
"\r\n" ..
|
||||||
"%s\r\n" ..
|
"%s\r\n" ..
|
||||||
".",
|
".",
|
||||||
|
|
@ -320,6 +328,7 @@ function SMTP:send_email(to_address, subject, message, from_name)
|
||||||
to_address,
|
to_address,
|
||||||
subject,
|
subject,
|
||||||
os.date("%a, %d %b %Y %H:%M:%S %z"),
|
os.date("%a, %d %b %Y %H:%M:%S %z"),
|
||||||
|
message_id,
|
||||||
message
|
message
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue