# Phoenix.Swoosh

[![Elixir CI](](
[![Module Version](](
[![Hex Docs](](
[![Total Download](](
[![Last Updated](](

Use Swoosh to easily send emails in your Phoenix project.

This module provides the ability to set the HTML and/or text body of an email by rendering templates.

## Installation

Add `:phoenix_swoosh` to your list of dependencies in `mix.exs`:

def deps do
    {:phoenix_swoosh, "~> 0.3"}

## Usage

Setting up the templates:

# web/templates/layout/email.html.eex
    <title><%= @email.subject %></title>
    <%= @inner_content %>

# web/templates/email/welcome.html.eex
  <h1>Welcome to Sample, <%= @username %>!</h1>

Passing values to templates:

# web/emails/user_email.ex
defmodule Sample.UserEmail do
  use Phoenix.Swoosh, view: Sample.EmailView, layout: {Sample.LayoutView, :email}

  def welcome(user) do
    |> from("")
    |> to(
    |> subject("Hello, Avengers!")
    |> render_body("welcome.html", %{username:})

## Copyright and License

Copyright (c) 2016 Swoosh contributors

Released under the MIT License, which can be found in [](./