View Source Swoosh.Adapters.SMTP2GO (Swoosh v1.17.2)

An adapter that sends email using the SMTP2GO API.

For reference: SMTP2GO API docs

This adapter requires an API Client. Swoosh comes with Hackney, Finch and Req out of the box. See the installation section for details.

Example

# config/config.exs
config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.SMTP2GO,
  api_key: "my-api-key"

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

Usage

import Swoosh.Email

new()
|> from({"Tony", "ironman@example.com"})
|> to({"Thanos", "thanos@example.com"})
|> reply_to("avengers@example.com")
|> cc("hulk@example.com")
|> bcc({"Steve Rogers", "steve.rogers@example.com"})
|> subject("I'm Ironman")
|> html_body("<h1>Hello</h1>")
|> text_body("Hello")

with template:

import Swoosh.Email

new()
|> from({"Tony", "ironman@example.com"})
|> to({"Thanos", "thanos@example.com"})
|> subject("I'm Ironman")
|> put_provider_option(:template_id, "123456")
|> put_provider_option(:template_data, %{"var1" => "value1"})

Summary

Functions

Link to this function

deliver(email, config \\ [])

View Source

Callback implementation for Swoosh.Adapter.deliver/2.

Callback implementation for Swoosh.Adapter.validate_config/1.

Callback implementation for Swoosh.Adapter.validate_dependency/0.