drewr / postal

Clojure email support
MIT License
586 stars 85 forks source link

DKIM signing #78

Open alephyud opened 7 years ago

alephyud commented 7 years ago

Is there an easy way to add a DKIM signature to an email before sending?

drewr commented 7 years ago

This should be doable with just an extra header. There's an example in the docs. Have you tried something like this?

(send-message {:from "john@draines.com"
                            :to ["mom@example.com" "dad@example.com"]
                            :cc "bob@example.com"
                            :subject "Hi!"
                            :body "Test."
                            :DKIM-Signature "v=1; a=rsa-sha256; ....."})
alephyud commented 7 years ago

The problem is that generating a DKIM-Signature header is not straightforward. There are libraries which can do it, like this one, but they require a MimeMessage object to make the header for.

Since Postal does not expose the MimeMessages it generates with make-jmessage, I have to fall back to javax.mail for the entire process.

This would be much easier if send-message had some kind of transform-before-send option - a function supplied by the user which could be applied to the message objects before sending. Would you consider introducing such an option?

May be I am overcomplicating this - please let me know if you know a better solution.