Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP metadata problems #22

Open
carlhoerberg opened this issue Apr 17, 2012 · 10 comments
Open

SMTP metadata problems #22

carlhoerberg opened this issue Apr 17, 2012 · 10 comments

Comments

@carlhoerberg
Copy link

I have problems to configure Postal for smtp. It seems like the metadata is stripped of.

(postal/send-message #^{:host "email-smtp.us-east-1.amazonaws.com"
                      :user (get (System/getenv) "AWS_SMTP_USER")
                      :pass (get (System/getenv) "AWS_SMTP_PASSWORD")
                      :ssl true }
                   {:from 'validated@exampled.com' :to 'me@example.com' :subject 'test' :body 'test'})

Ignores the smtp settings and uses sendmail instead..

@carlhoerberg
Copy link
Author

when i removed "#^" it worked.. why is that? should the documentation be updated?

@drewr
Copy link
Owner

drewr commented Apr 17, 2012

Yes, that is a documentation bug. Clojure previously used #^{} for metadata.

@carlhoerberg
Copy link
Author

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

@carlhoerberg
Copy link
Author

i've tested with both Clojure 1.3 and 1.4. Postal version 1.7.1

@drewr drewr reopened this Apr 17, 2012
@drewr
Copy link
Owner

drewr commented Apr 17, 2012

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.

@drewr
Copy link
Owner

drewr commented Apr 19, 2012

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?

@carlhoerberg
Copy link
Author

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))

@carlhoerberg
Copy link
Author

oh! now i get it, the meta data is "attached" to the message, not to the function call..

@carlhoerberg
Copy link
Author

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

@drewr
Copy link
Owner

drewr commented Apr 19, 2012

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!

carlhoerberg added a commit to carlhoerberg/postal that referenced this issue Apr 19, 2012
gislik pushed a commit to gislik/postal that referenced this issue Jun 18, 2013
gislik pushed a commit to gislik/postal that referenced this issue Jun 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants