-
Notifications
You must be signed in to change notification settings - Fork 11
/
core.clj
27 lines (25 loc) · 919 Bytes
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns framework.mail.core
(:require
[cuerdas.core :as cu]
[postal.core :as pc]))
(defn- make-body
[body atts]
(let [body-payload [:alternative
{:type "text/plain"
:content (cu/strip-tags body)}
{:type "text/html"
:content body}]
attachments (if (string? atts) (vector atts) atts)
file-map #(hash-map :type :attachment :content (java.io.File. %))]
(vec (concat body-payload (map file-map attachments)))))
(defn send-email!
"Sending a mail with 'postal.core'"
[{mail-config :xiana/emails}
{:keys [to cc bcc subject body attachments]}]
(pc/send-message mail-config
{:from (:from mail-config)
:to to
:cc cc
:bcc bcc
:subject subject
:body (make-body body attachments)}))