Swoosh v0.21.0 Swoosh.Adapters.AmazonSES View Source

An adapter that sends email using the Amazon Simple Email Service Query API.

This email adapter makes use of the Amazon SES SendRawEmail action and generates a SMTP style message containing the information to be emailed. This allows for greater more customizable email message and ensures the capability to add attachments. As a result, however, the gen_smtp dependency is required in order to correctly generate the SMTP message that will be sent.

Ensure sure you have the dependency added in your mix.exs file.

# You only need to do this if you are using Elixir < 1.4
def application do
  [applications: [:swoosh, :gen_smtp]]
end

def deps do
  [{:swoosh, "~> 0.10.0"},
   {:gen_smtp, "~> 0.12.0"}]
end

See Also:

Amazon SES Query Api Docs

Amazon SES SendRawEmail Documentation

Example

# config/config.exs
config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.AmazonSES,
  region: "region-endpoint",
  access_key: "aws-access-key",
  secret: "aws-secret-key"

# lib/sample/mailer.ex
defmodule Sample.Mailer do
  use Swoosh.Mailer, otp_app: :sample
end

Using with tags and configuration set

import Swoosh.Email

new()
|> from("guybrush.threepwood@pirates.grog")
|> to("elaine.marley@triisland.gov")
|> subject("Mighty Pirate Newsletter")
|> text_body("Hello")
|> put_provider_option(:tags, [%{name: "name1", value: "test1"}])
|> put_provider_option(:configuration_set_name, "configuration_set_name1")

Link to this section Summary

Link to this section Functions

Link to this function

deliver(email, config \\ []) View Source

Delivers an email with the given config.

Callback implementation for Swoosh.Adapter.deliver/2.