-
Notifications
You must be signed in to change notification settings - Fork 10
1.4. Messaging
Sergey Sobko edited this page Feb 22, 2018
·
1 revision
To send or receive emails, do this:
(require '[flower.credentials :as credentials])
(require '[flower.messaging.core :as messaging.core]
'[flower.messaging.proto :as messaging.proto])
(def login (credentials/get-credentials :account :login))
(def password (credentials/get-credentials :account :password))
(def domain (credentials/get-credentials :account :domain))
(def email (credentials/get-credentials :account :email))
;; Initialize our messaging component for authentication
(def msg-component (messaging.core/start-component {:auth {:message-box-username login
:message-box-password password
:message-box-domain domain
:message-box-email email}
:context {}}))
;; Our exchange servers definition
(def our-messaging (messaging.core/messaging msg-component
{:our-mail {:messaging-type :exchange}}))
Or this:
(require '[flower.macros :as macros])
(require '[flower.messaging.core :as messaging.core]
'[flower.messaging.proto :as messaging.proto])
(macros/with-default-credentials
(def our-mail (messaging.core/get-messaging)))
Now let's search for the first message from the top in our inbox:
(def top-message (first (messaging.proto/search-messages our-mail
{:count 1 :load-body true})))
The structure of the message is very simple. You can even change its recipients and resend it to a specific email with this:
(messaging.proto/send-message! (assoc top-message
:msg-recipients
'("[email protected]")))