Giter VIP home page Giter VIP logo

pewpew's Introduction

PewPew

This is a minimal client for the mailgun service.

Why does it exist? While dealing with the mailgun API is pretty straightforward, I wanted to create a simple hex package that I could reuse across my other systems that might need it later on.

Installation

Add to your dependencies:

def deps do
  [{:pewpew, "~> 0.1.0"}]
end

Usage

First, set some configuration options in config.exs (or the env-specific version):

use Mix.Config

config :pewpew,
  from: "default `from` address",
  key: "your API key from mailgun",
  domain: "the domain you wish to use in mailgun"

You can then create and send a mailer like so:

# Create a new mailer
m = PewPew.Mailer.new(
  to: "[email protected]",
  subject: "A subject!",
  text: "Plain-text body"
)

# Send the mailer
PewPew.Mailer.send(m)

There are a number of functions inside the PewPew.Mailer class, and they're hopefully pretty easy to understand. The functions are designed to be easily integrated inside a pipeline, so you can modify the struct pretty easily if you do not have all of the attributes at the time of creation. As an example:

PewPew.Mailer.new()
|> PewPew.Mailer.set_to("[email protected]")
|> PewPew.Mailer.set_cc("[email protected]")
|> PewPew.Mailer.set_bcc("[email protected]")
|> PewPew.Mailer.set_subject("Hello!")
|> PewPew.Mailer.set_text("This is some text content")
|> PewPew.Mailer.set_html("<p>Some <b>fancy</b> HTML content!</p>")
|> PewPew.Mailer.send()

Full documentation for this project can be found at https://hexdocs.pm/pewpew.

pewpew's People

Stargazers

Nguyen Vinh Linh avatar

Watchers

Mylan Connolly avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.