Seeking Solution: Detecting Links in HTML Body Despite Content-Transfer-Encoding

  1. Is there a way to detect links within the HTML body? Currently, I’m using Lua’s matching functionality to find links. However, this method fails when sending emails with ‘Content-Transfer-Encoding’ (e.g., quoted-printable), as the transfer encoding introduces additional characters to the HTML content, causing gmatch to malfunction. Is there a solution to this issue?

Below is the code I’m currently using:

`
local function findUrls(template)
local foundUrls = {}
local count = 1
local function pregMatchAll(pattern, input)
local matches = {}
for match in input:gmatch(pattern) do
table.insert(matches, {match})
end
return matches
end

local function addUrls(matches, tag)
    local result = {}
    for _, element in ipairs(matches) do
        for _, value in pairs(element) do
            foundUrls[value] = count
            count = count +1
        end
    end
end

local matches = pregMatchAll('<a%s+.-href%s*=%s*["\'](.-)["\']', template)
addUrls(matches, "a")
matches = pregMatchAll('<area%s+.-href%s*=%s*["\'](.-)["\']', template)
addUrls(matches, "area")
return foundUrls

end
`

  1. Is there a way to determine if ‘Content-Transfer-Encoding’ is utilized in an email using the Kumo functionality?

Hey there @kindhearted-deer, thanks for posting. Please read the “Troubleshooting” and “How to Ask for Help” buttons below. If you would like a 1:1 support session from the KumoMTA team, details are at the “Book a Support Session” button below.

You should be able to test for “Content-Transfer-Encoding” as a header or in the body using a similar method as above.
A detailed body parser for KumoMTA has not been published at this time.

is there any option for point 1 ?

There is no built in method at this time. However, it is something we can add to the “needs funding” list