Open carlhoerberg opened 12 years ago
when i removed "#^" it worked.. why is that? should the documentation be updated?
Yes, that is a documentation bug. Clojure previously used #^{} for metadata.
nope still doesn't cut it, only a clean map is what works for me..
(i thought it worked in development previously, but it used sendmail, which actually worked on my machine..)
i've tested with both Clojure 1.3 and 1.4. Postal version 1.7.1
Ugh! You're right. This is due to a contribution that I didn't vet too well, and reveals a lack of test coverage. Let me work on fixing.
After looking at it further and trying it myself, there doesn't seem to be an issue there. Can you give me a failing test case?
In following code does only send-message3
throw javax.mail.AuthenticationFailedException
, although all of them should've.
(ns postal-bug.core
(:require [postal.core :as postal]))
(defn send-message [message]
(postal/send-message ^{:host "email-smtp.us-east-1.amazonaws.com"
:ssl true }
message))
(def smtp-settings
{:host "email-smtp.us-east-1.amazonaws.com"
:ssl true })
(defn send-message2 []
(postal/send-message ^smtp-settings
{:from "foo@example.com"
:to "bar@example.com"
:subject "foo"
:body "bar"}))
(defn send-message3 []
(postal/send-message ^{:host "email-smtp.us-east-1.amazonaws.com"
:ssl true }
{:to "foo@example.com"
:from "bar@example.com"
:subject "foo"
:body "bar"}))
(defn -main [& args]
(send-message {:from "foo@example.com"
:to "bar@example.com"
:subject "foo"
:body "bar"})
(send-message2)
(send-message3))
oh! now i get it, the meta data is "attached" to the message, not to the function call..
but it's pretty uncommon to use different smtp settings per message within the same application, don't you think?
maybe an example with a "global" smtp-settings var in the README would be appropriate? would've at least helped a newbie like me :P
Sorry! Didn't know there was a misunderstanding of the meta usage. :-)
It may not be common, but as a library it shouldn't dictate what people do. Perhaps you have a policy where you need to send out a batch of messages in a stream but for billing reasons they each need to go through a different provider. The server info is ancillary to the content of the message, so meta seems like a logical place. If you'd rather use the two-arity version, go right ahead!
Thanks for using postal!
I have problems to configure Postal for smtp. It seems like the metadata is stripped of.
Ignores the smtp settings and uses sendmail instead..