Skip to content

Saurav-S-Purushothaman/envelope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Envelope README

envelope

envelope is a Clojure library that serves as a wrapper around the Jakarta Mail (formerly JavaMail) API. It creates idiomatic way to send emails over SMTP in Clojure.

Usage

Creating multipart emails

A simple example

;; All the functions used in this example which are not from
;; clojure.core namespace are from envelope.core namespace

(require '[envelope.core :refer all])

(let [username "sauravapprehensiveice@outlook.com"
      password "password"
      props (properties username "smtp-mail.outlook.com" "587")
      session (create-session! props username password)
      ;; Multimedia part
      html1 (html-part "<h1>Hello World</h1>")
      html2 (html-part "<h2>Hello World</h2>")
      multi (multi-part)
      message (mime-message username
                            "saurav.kudajadri@gmail.com"
                            "Subject"
                            "Saurav"
                            session)]
  ;; Attach body to multipart
  (attach-body multi html1)
  (attach-body multi html2)
  ;; Set content of the message
  (set-content message multi)
  ;; Send the email
  (send-email! message))

See, the number of lines of code is considerably less when compared to java :-)

License

Copyright © 2024 FIXME

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

About

A simple clojure library to send messages over SMTP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors