- 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
`
- Is there a way to determine if ‘Content-Transfer-Encoding’ is utilized in an email using the Kumo functionality?