CrossClj

0.9.0 docs

SourceDocs



RECENT
    VARS
    clear-mail
    copy-mailbox
    count-mail
    create-mailbox
    create-mailer
    get-mail
    init-mail
    list-mail
    mailbox
    mailer
    send-bulk
    send-mail

    « Index of all namespaces of this project

    (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
    (copy-mailbox from to)
    copies the contents of one mailbox to another
    
    (def boxA (mailbox {:type :imap
                        :host "mail.webfaction.com"
                        :auth {:username "zcaudate_spirit"
                               :password "spirit"}}))
    
    (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
    (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
    (create-mailbox m)
    creates a mailbox for use with hara.component
    
    (create-mailbox {:type :mock
                     :addresses ["a@a.com"]})
    
    (create-mailbox {:type :imap
                    :host "mail.webfaction.com"
                     :auth {:username "zcaudate_spirit"
                            :password "spirit"}})
    (create-mailer m)
    creates a mailer for use with hara.component
    
    (create-mailer {:type :mock})
    
    (create-mailer {:type :local})
    
    (create-mailer {:type :smtp
                    :host "smtp.webfaction.com"
                    :auth {:username "zcaudate_spirit"
                          :password "spirit"}})
    (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"})
    (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
    (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"}])
    (mailbox m)
    creates an active mailbox
    
    (mailbox {:type :mock})
    ;; => #mailbox.mock{:id "8c465d04-fdaa-4401-997e-cd6ed3d9d732",
    ;;                  :messages 0, :addresses #{}}
    
    (mailbox {:type :pop3
              :host "mail.webfaction.com"
              :auth {:username "zcaudate_spirit"
                     :password "spirit"}})
    (mailer m)
    creates an active mailer
    
    (mailer {:type :mock})
    
    (mailer {:type :smtp
             :host "smtp.webfaction.com"
            :auth {:username "zcaudate_spirit"
                    :password "spirit"}})
    (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"}]))
    (send-mail mailer message)
    sends mail to the given address
    
    (-> (mailer {:type :mock})
       (send-mail {:to ["a@a.com"]
                    :body "Test"}))