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

Add SMTP mail host configuration options #5

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions resources/config/core.edn.base
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@

:mail-sender "sender@example.com"

:mail-host-config {:host "smtp.example.com"
:user "yourusername"
:pass "yourpassword"
:ssl true
:tls false
:port 587}

:data-dir "/path/to/data/directory"}
8 changes: 6 additions & 2 deletions src/clj/salava/core/mail.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@

(def mail-sender (:mail-sender config))

(def mail-host-config (:mail-host-config config))

(defn send-mail [subject message recipients]
(try+
(let [data {:from mail-sender
:to recipients
:subject subject
:body [{:type "text/plain; charset=utf-8"
:content message}]}]
(send-message data))
(if (nil? mail-host-config)
(send-message data)
(send-message mail-host-config data)))
(catch Object _
;TODO log an error
)))
Expand Down Expand Up @@ -44,4 +48,4 @@
message (str fullname "\n\nYou have added the e-mail address '" email "' to your\naccount at " site-url". In order to complete the registration of\nthis email, you must confirm it by clicking the link below.\n\n"
email-verification-link
"\n\nIf the web address does not appear as a link, you must copy the address out\nof this email, and paste it into the address bar of your web browser.\n\nIf you do not confirm this e-mail in 5 days, it will be unregistered from\nyour account.\n")]
(send-mail subject message [email])))
(send-mail subject message [email])))