• Stars
    star
    2
  • Language
    Julia
  • License
    Other
  • Created over 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mandrill API in Julia

I do not use Mandrill any more, after they changed their subscription models. Therefore, this package is currently unmaintained. I'll be happy to take PR's if anyone is interested.

A Julia package for the Mandrill REST API

Build Status

Mandrill is a mail delivery provider for transactional email, created by the folks at Mailchimp. This package is a low overhead, lightweight wrapper around Mandrill's REST api.

Mandrill's REST API uses JSON messages to send emails, setup templates, or query reports. To use this package, create the input message as a Julia Dictionary, using the schema in the Mandrill API Documentation. Then, call the corresponding julia method. The call results are returned as JSON documents from Mandrill, which are converted Julia Dictionaries.

Any errors from the API call will result in a Julia ErrorException being thrown. This will exit the process if not caught.

Each API endpoint corresponds to a single method. Mandrill API endpoints are structured as group/name.ext. This is mapped as a Mandrill.group_name method in Julia. For example, the endpoint /user/info.json is mapped to the method Mandril.user_info(). These methods typically take a Julia Dictionary as their only arguments. For endpoints that do not need any inputs (other than the authentication key,) the method can be called without arguments.

The Mandrill authentication key can be provided via a SHELL environment variable MANDRILL_KEY (which must be set before the package is loaded) or explicitly set via the Mandrill.key(key_string) method call. The key need not be provided again for each method call.

Note that email attachments are sent as base64 encoded strings in the Mandrill JSON API. Julia base library includes a base64encode method that can be used for this purpose.

Installation

Pkg.add("Mandrill")

Example Usage

using Mandrill
Mandrill.key("axfGadhf4E....")

Mandrill.user_info()
#Dict{AbstractString,Any} with 7 entries:
#  "public_id"    => "WBdNPiLFZ............."
#  "created_at"   => "2015-11-02 14:15:30.37005"
#  "hourly_quota" => 25
#  "username"     => "avik........"
#  "reputation"   => 0
#  "backlog"      => 0
#  "stats"        => Dict{AbstractString,Any}("today"=>Dict{AbstractString,Any}("hard_bounces"=>0,"unique_opโ€ฆ

To send a message, it may be simplest to create a Dict inline:

s = Dict(
  "message" => Dict(
    "html" => "<p> Example HTML Content </p>",
    "text" => "Example Test Content",
    "subject" => "Example Subject",
    "from_email" => "[email protected]",
    "from_name" => "Example Name",
    "to" => [
      Dict(
        "email" => "[email protected]",
        "name" => "Recipient Name",
        "type" => "to"
        )
    ],
    "headers" => Dict(
      "Reply-To" => "[email protected]"
    ),
    "important" => false,
    "tags" => [
      "password-resets",
      "user-initiated"
    ],
    "metadata" => Dict(
      "website" => "www.example.com"
    )
  ),
  "async" => false,
  "ip_pool" => "Main Pool"
)
#stick a @compat in front of Dict creation for julia 0.3

Mandrill.messages_send(s)
#1-element Array{Any,1}:
# Dict{AbstractString,Any}("_id"=>"85115b2d653748e19a37cd851b0fd1d2","status"=>"sent",
#                      "reject_reason"=>nothing,"email"=>"[email protected]")

Alternatively, you could create the Dict piecemeal.

s = Dict{String, Any}()
message = Dict{String, Any}()
message["html"] = "<p>Example HTML Content</p>"
message["text"] = "Example text content"
message["subject"] = "[email protected]"
rcpt1 = Dict{String, Any}()
rcpt1["email"] = "[email protected]"
rcpt1["name"] = "Recipient One"
rcpt1["type"] = "to"
rcpt2 = Dict{String, Any}()
rcpt2["email"] = "[email protected]"
rcpt2["name"] = "Recipient Two"
rcpt2["type"] = "cc"
message["to"] = [rcpt1, rcpt2]
s["message"]=message
s["async"] = true

Mandrill.messages_send(s)
#2-element Array{Any,1}:
# Dict{AbstractString,Any}("_id"=>"59b5a7b930b44a21953ae7975c657fcf",
#                    "status"=>"queued","email"=>"[email protected]")
# Dict{AbstractString,Any}("_id"=>"2dd208db6ad546dfae8a3a2466137260",
#                    "status"=>"queued","email"=>"[email protected]")

More Repositories

1

GameZero.jl

Zero overhead game development library for the Julia programming language
Julia
181
star
2

Taro.jl

Read and write Excel, Word and PDF documents in Julia
Julia
117
star
3

SMTPClient.jl

Send emails from Julia
Julia
65
star
4

MiniFB.jl

Render pixels on screen
Julia
47
star
5

Whisper.jl

Implementation of OpenAI Whisper model based on whisper.cpp
Julia
46
star
6

Ito.jl

A Julia package for quantitative finance
Julia
35
star
7

Julia-High-Performance

Julia High Performance
Jupyter Notebook
25
star
8

mltraining

Jupyter Notebook
23
star
9

learn-julia

A Julia Tutorial
Julia
12
star
10

SlackSDK.jl

Julia interface to the Slack Web API
Julia
8
star
11

GZWorkshop

GameZero Workshop for JuliaCon 2021
Julia
6
star
12

nlp-workshop

Jupyter Notebook
6
star
13

julia-zmq-mongrel

ZMQ and Mongrel handlers for Julia
Julia
6
star
14

MLPrague

Julia
4
star
15

mockingbird-ruby

Smullyan's birds in Ruby
Ruby
4
star
16

julia-talks

Jupyter Notebook
4
star
17

www.juliahighperformance.com

HTML
4
star
18

juliacon15

Java
3
star
19

SimpleDate.jl

Simple Date Time support for Julia. EXPERIMENTAL
Julia
2
star
20

Mongrel2.jl

Mongrel2 handlers in Julia
Julia
2
star
21

RubyCall.jl

Julia
1
star
22

Holiday2022

A simple holiday themed game using GameZero.jl
Julia
1
star
23

.julia

My default installed julia packages
1
star
24

ODSC

Julia for DataScientists at ODSC London 2017
Jupyter Notebook
1
star
25

JuliaDT.jl

Julia backend for Eclipse plugin
Julia
1
star
26

View5D.jl

Julia
1
star
27

SnowballBuilder

BinaryBuilder recipes for Snowball stemmer
Julia
1
star
28

SimpleML.jl

Textbook implementations of some Machine Learning Algorithms in Julia.
Julia
1
star