Liking cljdoc? Tell your friends :D

hara.platform.mail


clear-mailclj

(clear-mail mailbox)

clears mail for the entire mailbox

(let [box (mailbox {:id :test :type :mock :addresses ["a@a.com"]})] (-> (mailer {:type :mock}) (send-bulk [{:to ["a@a.com"] :body "Test A"} {:to ["a@a.com"] :body "Test B"} {:to ["a@a.com"] :body "Test C"}])) (clear-mail box) (count-mail box)) => 0

clears mail for the entire mailbox

(let [box (mailbox {:id :test
                    :type :mock
                    :addresses ["a@a.com"]})]
  (-> (mailer {:type :mock})
      (send-bulk [{:to ["a@a.com"] :body "Test A"}
                  {:to ["a@a.com"] :body "Test B"}
                  {:to ["a@a.com"] :body "Test C"}]))
  (clear-mail box)
  (count-mail box))
=> 0
raw docstring

copy-mailboxclj

(copy-mailbox from to)

copies the contents of one mailbox to another

(def boxA (mailbox -test-imap-))

(def boxB (mailbox {:id :test :type :mock}))

(copy-mailbox boxA boxB)

(= (mapv (comp :all-headers object/to-data) (list-mail boxA)) (mapv (comp :all-headers object/to-data) (list-mail boxB))) => true

copies the contents of one mailbox to another

(def boxA (mailbox -test-imap-))

(def boxB (mailbox {:id :test
                    :type :mock}))

(copy-mailbox boxA boxB)

(= (mapv (comp :all-headers object/to-data) (list-mail boxA))
   (mapv (comp :all-headers object/to-data) (list-mail boxB)))
=> true
raw docstring

count-mailclj

(count-mail mailbox)

counts the number of mail in the mailbox

(let [box (mailbox {:id :test :type :mock :addresses ["a@a.com"]})] (-> (mailer {:type :mock}) (send-bulk [{:to ["a@a.com"] :body "Test A"} {:to ["b@b.com"] :body "Test B"} {:to ["c@c.com"] :body "Test C"}])) (count-mail box)) => 1

counts the number of mail in the mailbox

 (let [box (mailbox {:id :test
                     :type :mock
                     :addresses ["a@a.com"]})]
   (-> (mailer {:type :mock})
       (send-bulk [{:to ["a@a.com"] :body "Test A"}
                   {:to ["b@b.com"] :body "Test B"}
                   {:to ["c@c.com"] :body "Test C"}]))
   (count-mail box))
=> 1
raw docstring

create-mailboxclj

(create-mailbox m)

creates a mailbox for use with hara.core.component

(create-mailbox {:type :mock :addresses ["a@a.com"]})

(create-mailbox -test-imap-)

creates a mailbox for use with hara.core.component

(create-mailbox {:type :mock
                 :addresses ["a@a.com"]})

(create-mailbox -test-imap-)
raw docstring

create-mailerclj

(create-mailer m)

creates a mailer for use with hara.core.component

(create-mailer {:type :mock})

(create-mailer {:type :local})

(create-mailer -test-smtp-)

creates a mailer for use with hara.core.component

(create-mailer {:type :mock})

(create-mailer {:type :local})

(create-mailer -test-smtp-)
raw docstring

get-mailclj

(get-mail mailbox i)

retrieves mail at a given index

(let [box (mailbox {:id :test :type :mock :addresses ["a@a.com"]})] (-> (mailer {:type :mock}) (send-mail {:to ["a@a.com"] :body "Test A"})) (-> (get-mail box 0) (object/to-data))) => (contains {:to ["a@a.com"] :body "Test A"})

retrieves mail at a given index

(let [box (mailbox {:id :test
                    :type :mock
                    :addresses ["a@a.com"]})]
  (-> (mailer {:type :mock})
      (send-mail {:to ["a@a.com"] :body "Test A"}))
  (-> (get-mail box 0)
      (object/to-data)))
=> (contains {:to ["a@a.com"]
             :body "Test A"})
raw docstring

init-mailclj

(init-mail mailbox messages)

sets the mailbox with the inital messages (let [box (mailbox {:id :test :type :mock})] (init-mail box (mapv message [{:to ["a@a.com"] :body "Test A"}])) (count-mail box)) => 1

sets the mailbox with the inital messages
(let [box (mailbox {:id :test
                    :type :mock})]
  (init-mail box (mapv message [{:to ["a@a.com"]
                                 :body "Test A"}]))
  (count-mail box))
=> 1
raw docstring

list-mailclj

(list-mail mailbox)

retrieves all mail in the mailbox

(let [box (mailbox {:id :test :type :mock :addresses ["a@a.com"]})] (-> (mailer {:type :mock}) (send-bulk [{:to ["a@a.com"] :body "Test A"} {:to ["a@a.com"] :body "Test B"} {:to ["a@a.com"] :body "Test C"}])) (-> (list-mail box) (object/to-data))) => (contains-in [{:body "Test A"} {:body "Test B"} {:body "Test C"}])

retrieves all mail in the mailbox

(let [box (mailbox {:id :test
                    :type :mock
                    :addresses ["a@a.com"]})]
  (-> (mailer {:type :mock})
      (send-bulk [{:to ["a@a.com"] :body "Test A"}
                  {:to ["a@a.com"] :body "Test B"}
                  {:to ["a@a.com"] :body "Test C"}]))
  (-> (list-mail box)
      (object/to-data)))
=> (contains-in [{:body "Test A"}
                {:body "Test B"}
                 {:body "Test C"}])
raw docstring

mailboxclj

(mailbox m)

creates an active mailbox

(mailbox {:type :mock}) ;; => #mailbox.mock{:id "8c465d04-fdaa-4401-997e-cd6ed3d9d732", ;; :messages 0, :addresses #{}}

(mailbox -test-pop3-)

creates an active mailbox

(mailbox {:type :mock})
;; => #mailbox.mock{:id "8c465d04-fdaa-4401-997e-cd6ed3d9d732",
;;                  :messages 0, :addresses #{}}

(mailbox -test-pop3-)
raw docstring

mailerclj

(mailer m)

creates an active mailer

(mailer {:type :mock})

(mailer -test-smtp-)

creates an active mailer

(mailer {:type :mock})

(mailer -test-smtp-)
raw docstring

messageclj

(message {:keys [from to cc bcc subject content text reply-to] :as m})

constructs a MimeMessage from a map

(-> (message {:from "z@z.com" :cc ["a@a.com"] :bcc ["b@b.com" "c@c.com"] :reply-to ["y@y.com"] :subject "Hello There" :body "This is Cool"}) (object/to-data) (select-keys [:all-headers :subject :body])) => {:all-headers [["From" "z@z.com"] ["Reply-To" "y@y.com"] ["Cc" "a@a.com"] ["Bcc" "b@b.com, c@c.com"] ["Subject" "Hello There"]] :subject "Hello There" :body "This is Cool"}

constructs a MimeMessage from a map

(-> (message {:from "z@z.com"
              :cc  ["a@a.com"]
              :bcc ["b@b.com" "c@c.com"]
              :reply-to ["y@y.com"]
              :subject "Hello There"
              :body "This is Cool"})
    (object/to-data)
    (select-keys [:all-headers :subject :body]))
=> {:all-headers [["From" "z@z.com"]
                  ["Reply-To" "y@y.com"]
                  ["Cc" "a@a.com"]
                  ["Bcc" "b@b.com, c@c.com"]
                 ["Subject" "Hello There"]]
    :subject "Hello There"
    :body "This is Cool"}

raw docstring

send-bulkclj

(send-bulk mailer messages)

sends a list of mail to the given address

(-> (mailer {:type :mock}) (send-bulk [{:to ["a@a.com"] :body "Test A"} {:to ["b@b.com"] :body "Test B"} {:to ["c@c.com"] :body "Test C"}]))

sends a list of mail to the given address

(-> (mailer {:type :mock})
    (send-bulk [{:to ["a@a.com"]
                :body "Test A"}
                {:to ["b@b.com"]
                 :body "Test B"}
                {:to ["c@c.com"]
                 :body "Test C"}]))
raw docstring

send-mailclj

(send-mail mailer {:keys [to cc bcc subject body] :as message})

sends mail to the given address

(-> (mailer {:type :mock}) (send-mail {:to ["a@a.com"] :body "Test"}))

sends mail to the given address

(-> (mailer {:type :mock})
    (send-mail {:to ["a@a.com"]
               :body "Test"}))
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close