I followed Swoosh docs but email doesn’t arrive.
https://hexdocs.pm/swoosh/Swoosh.Adapters.AmazonSES.html
There’s a mention about IAM role and :security_token. But I couldn’t find further information about it.
IAM role
… but you also need to include additionalX-Amz-Security-Tokenheader to that request.You can do that by adding
:security_tokento:provider_options.
Other than that SES works without it.
I could send emails regardless of if I added the |> put_provider_option(:security_token, “your_token_here”) header or not.
It’s been frustrating. Please let me know if you have any idea I can make it work.
This is my config.
# config/prod.exs
config :swoosh, :api_client, Feder.Finch
# config/runtime.exs
config :feder, Feder.Mailer,
  adapter: Swoosh.Adapters.AmazonSES,
  region: "us-east-2",
  access_key: System.get_env("SMTP_ID"),
  secret: System.get_env("SMTP_SECRET")
This is AWS policy
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ses:SendRawEmail",
            "Resource": "*"
        }
    ]
}
I’ve got deps.
defp deps do
  [
    ...
    {:swoosh, "~> 1.3"},
    {:finch, "~> 0.13"},
    {:gen_smtp, "~> 1.0"},
    ...
  ]
end
This is what server logs for requests.
Feder.Finch.post(
  "https://email.us-east-2.amazonaws.com", 
  [
    {"Authorization", "AWS4-HMAC-SHA256 Credential=A...M/20221227/us-east-2/ses/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=e...d"}, 
    {"Content-Length", "1061"}, 
    {"Content-Type", "application/x-www-form-urlencoded"}, 
    {"Host", "email.us-east-2.amazonaws.com"}, 
    {"X-Amz-Date", "20221227T213132Z"}
  ],
  "Action=SendRawEmail&RawMessage.Data=Q29udGVudC1UeXBlO...&Version=2010-12-01", 
  %Swoosh.Email{ ... }
)
            



















