Permalink
Browse files

Fix password recovery email.

  • Loading branch information...
1 parent cbcaeda commit 339d282db05cbcf234b3ede38b82645a60c8238d @technomancy technomancy committed Mar 10, 2012
Showing with 14 additions and 11 deletions.
  1. +1 −0 resources/config.clj
  2. +13 −11 src/clojars/web/user.clj
View
@@ -5,6 +5,7 @@
:repo "/home/clojars/repo"
:bcrypt-work-factor 12
:mail {:hostname "smtp.gmail.com"
+ :from "noreply@clojars.org"
:username "clojars@pupeno.com"
:password "fuuuuuu"
:port 465 ; If you change ssl to false, the port might not be effective, search for .setSSL and .setSslSmtpPort
View
@@ -112,17 +112,19 @@
;; TODO: move this to another file?
(defn send-mail [to subject message]
- (doto (SimpleEmail.)
- (.setHostName ((config/config :mail) :hostname))
- (.setAuthentication ((config/config :mail) :username)
- ((config/config :mail) :password))
- (.setSslSmtpPort (str ((config/config :mail) :port)))
- (.setSSL ((config/config :mail) :ssl))
- (.setFrom "clojars@pupeno.com" "Clojars")
- (.addTo to)
- (.setSubject subject)
- (.setMsg message)
- (.send)))
+ (let [{:keys [hostname username password port ssl from]} (config/config :mail)
+ mail (doto (SimpleEmail.)
+ (.setHostName hostname)
+ (.setSslSmtpPort (str port))
+ (.setSmtpPort port)
+ (.setSSL ssl)
+ (.setFrom from "Clojars")
+ (.addTo to)
+ (.setSubject subject)
+ (.setMsg message))]
+ (when (and username password)
+ (.setAuthentication username password))
+ (.send mail)))
(defn forgot-password [{email-or-username "email-or-username"}]
(when-let [user (find-user-by-user-or-email email-or-username)]

0 comments on commit 339d282

Please sign in to comment.