3

I'm using Scrivener to write emails for my business. I then use the "compile" feature to export to HTML.

I'm wondering if there is a way to use spam-assassin to do a local test on a folder with multiple html emails within it.

I would only be looking for testing of the subject line and the content of the email. So I don't want to fool with sending the email anywhere. Plus, the html files won't have email headers.

Any advice is appreciated.

0

Some SpamAssassin tests use the mail headers, so they're sort of required. At least, without them, your results will be a lot less accurate.

I'd suggest the easiest approach is to stuff the HTML documents into an email. This is pretty easy to do with a trivial shell script. Note this and the next example use flip (which you may have to install) to convert to email's CRLF line endings. You could also use sed, I suppose. Or maybe it's fine without it.

cat <<HEADER - in/message.html | flip -m > out/message.eml
From: "Your Company Name" <email@companyname.example.com>
To: "Your Name" <your-email@example.com>
Date: $(date -R)
Content-type: text/html; charset=utf-8
Content-transfer-encoding: binary
Subject: Your Subject Here

HEADER

Downside, that leaves you with a non-MIME HTML-only message. You may have to disable a SpamAssassin rule which will dock your message for being HTML-only.

Another option is the mime-construct utility, which again you may have to install. Then you'd do:

mime-construct --to '"Your Name" <your-email@example.com>' \
               --subject "Your Subject Here" \
               --header 'From: "Your Company Name" <email@companyname.example.com>' \
               --header "Date: $(date -R)" \
               --multipart 'multipart/alternative' --output \
               --type 'text/plain; charset=utf-8' --file in/message.txt \
               --type 'text/html; charset=utf-8' --file in/message.html \
    | flip -m - > out/message.eml

You could use lynx -dump to make your plain-text alternative (e.g., lynx -dump in/message.html > in/message.txt)

You should then be able to run the generated file through SpamAssassin as an email.

It should go without saying that you need to follow other email best practices (confirmed opt-in, easy ubsubscribe, etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.