View Source Swoosh.Adapters.MsGraph (Swoosh v1.16.5)

An adapter that sends email using the Microsoft Graph API.

For reference: Microsoft Graph 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.

Dependency

Microsoft Graph adapter requires :gen_smtp to work properly. :gen_smtp is only used to encode the email body to MIME format.

Configuration options

  • :auth - either a function, a {mod, func, args} tuple, or a string that returns/is an OAuth 2.0 access token.
  • :base_url - the base URL to use as the Microsoft Graph API endpoint. Defaults to the standard Microsoft Graph API endpoint.

Example

# config/config.exs
config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.MsGraph,
  auth: fn -> Sample.OAuthTokenRequester.request_token() end

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

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.