원본 프로젝트 : migadu/mailex
1
0
포크 0
Go to file
Michael Bruderer bb9abe2cdf Merge branch 'master' of Michael/mailex into master 2016-02-21 22:13:21 +00:00
config initial commit 2015-11-25 17:10:43 +01:00
lib add missing envelope format 2016-02-21 23:11:37 +01:00
test minimal test 2015-11-25 18:21:38 +01:00
.DS_Store initial commit 2015-11-25 17:10:43 +01:00
.gitignore initial commit 2015-11-25 17:10:43 +01:00
README.md initial commit 2015-11-25 17:11:10 +01:00
mix.exs initial commit 2015-11-25 17:10:43 +01:00
mix.lock initial commit 2015-11-25 17:10:43 +01:00

README.md

Mailex

Simple wrapper around gen_smtp for sending emails.

Installation

If available in Hex, the package can be installed as:

  1. Add mailex to your list of dependencies in mix.exs:

    def deps do [{:mailex, "~> 0.0.1"}] end

  2. Ensure mailex is started before your application:

    def application do [applications: [:mailex]] end

Usage

To create an email:

email = %Mailex.Email{
  from: %Mailex.Address{name: "Dejan Strbac", address: "me@dejanstrbac.com"},
  to: [%Mailex.Address{name: "Dejo", address: "dejan.strbac@gmail.com"}],
  subject: "Hi there",
  text: "Hello World",
  attachments: [Mailex.Attachment.inline!("test/data/logo.gif")]
 }

To render it:

Mailex.Render.render(email)

To dump emails to console, just deliver without config:

Mailex.deliver(email)

To use a smtp server, provide settings:

Mailex.deliver(email, [
  relay:    "smtp.migadu.com",
  username: "USERNAME",
  password: "PASSWORD",
  port:      587,
  tls:      :always
  ssl:      true,
  auth:     :always
])