drewr / postal

Clojure email support
MIT License
587 stars 85 forks source link

Added support for mail forwarding - recipients can now override to, cc, and bcc #52

Open oysteinjakobsen opened 10 years ago

oysteinjakobsen commented 10 years ago

MOTIVATION

Sometimes, for example when expanding a mailing list address and forwarding a mail to each member, it is useful to be able to override what's given in :to, :cc, and :bcc by explicitly setting which recipients should get the forwarded mail. It is however important that the original mail headers remain intact so that the recipients see who received the original mail and is able to reply (to all).

HOW TO USE IT

You can now specify :recipients. If given, the mail will be sent to them instead to those given in :to, :cc, and :bcc:

postal.core> (send-message {:from "foo@bar.dom"
                            :to "mailinglist@bar.dom"
                            :cc "another@another.dom"
                            :recipients ["member1@foo.dom" "member2@another.dom"]
                            :subject "An announcement to all members!"
                            :body "Regards."}

CHANGES

The most effective way to implement this was to change make-jmessage to do the job. This function was renamed to make-jmessage-with-recipients and now returns a map:

{:jmsg the-jmessage-object :recipients array-of-internet-addresses }

The recipients are either those given in :recipients, if any, or those given in :to, :cc, and :bcc.

The function recipients was removed.

I also added functions smtp-send-single* and smtp-connect* in order to write tests.

drewr commented 9 years ago

Thanks @oysteinjakobsen! I've wanted better envelope support but hadn't done it. Couple of thoughts. I'm not sure I like implementing it in make-jmessage. I think it should really return a jmessage. I wonder if it's worth promoting the internal notion of a message to its own Message type and have the envelope (sender and recipients) info be a first-class part of that?

sr1234 commented 9 years ago

Hi Drew,

I am running into an urgent matter - need support asap. Could I ask for someone from your support team to call me? It is so urgent that just need to get someone on the phone. Happy to discuss support options for our business with them, but I need to have our ES up by tomorrow. Rebooted it, and getting an error. Won't start anymore!! Can't stress how urgent this is. Many thanks. I couldn't find a number to call from your website.

[FYI, This project is unrelated to Elasticsearch. --Drew]