Swoosh.Adapters.Gmail (Swoosh v1.5.0) View Source
An adapter that sends email using Gmail api
For reference: Gmail API docs
Dependency
Gmail adapter requires Mail
dependency to format message as RFC 2822 message.
{:mail, ">= 0.0.0"}
Because Mail
library removes Bcc headers, they are being added after email is
rendered, in adapter code.
Example
# config/congig.exs
config :sample, Sample.Mailer
adapter: Swoosh.Adapters.Gmail,
access_token: {:system, GMAIL_API_ACCESS_TOKEN}
# To deal with token refresh, it could be a better idea to pass the access token
# in via deliver config explicitly, if you don't update the environment variable
# periodically. e.g.
MyMailer.deliver(my_email, access_token: my_access_token)
# lib/sample/mailer.ex
defmodule Sample.Mailer do
use Swoosh.Mailer, otp_app: :sample
end
Required config parameters
:access_token
valid OAuth2 access token Required scopes:- gmail.compose See https://developers.google.com/oauthplayground when developing
Link to this section Summary
Functions
Callback implementation for Swoosh.Adapter.validate_config/1
.
Callback implementation for Swoosh.Adapter.validate_dependency/0
.
Link to this section Functions
Callback implementation for Swoosh.Adapter.validate_config/1
.
Callback implementation for Swoosh.Adapter.validate_dependency/0
.