drewr/postal — pull request #52 by oysteinjakobsen (2014-10-05 12:10:40+00:00)
Title: Added support for mail forwarding - recipients can now override to, cc, and bcc

#### 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.