type.inbound and
any(attachments,
// HTML file (html, shtm, xht, etc.)
regex.imatch(.file_extension, '^[sdx]{0,1}ht[ml]{0,2}$') and
any(file.explode(.),
// Top level file strings contain script but not html tag
.depth == 0 and
any(.scan.strings.strings, strings.icontains(., "<script")) and
not any(.scan.strings.strings, strings.icontains(., "<html"))
)
)
and (
not profile.by_sender_email().solicited
or sender.email.domain.domain == "delivrto.me"
)
Playground
Test against your own EMLs or sample data.