---
title: How to fix Swoosh error
date: '2023-04-04T00:00:00+00:00'
url: https://www.abhinav.co/swoosh-module-false-is-not-available-error
summary: If you are seeing 'module false is not available' error when using Swoosh,
  then you need to make a small change to fix this error
tags:
- Elixir
- Phoenix
- Swoosh
- Email
author: Abhinav Saxena
---

# How to fix Swoosh error

Swoosh is the default email library in Phoenix. It requires an adapter (like AWS SES) and a couple of extra libraries to work properly.

For example, if you are using (AmazonSES adapter)[https://hexdocs.pm/swoosh/Swoosh.Adapters.AmazonSES.html], then you will need to add (gen_smtp)[https://hex.pm/packages/gen_smtp] library as a dependency

```elixir
# if your mix.exs add this inside defp deps function
{:gen_smtp, "~> 1.2"}
```

You will also need to set SES specific environment variables and update your config.exs file
```elixir
config :example_app, ExampleApp.Mailer,
  adapter: Swoosh.Adapters.AmazonSES,
  region: System.get_env("AWS_SES_SMTP_REGION_ENDPOINT"),
  access_key: System.get_env("AWS_ACCESS_KEY"),
  secret: System.get_env("AWS_SECRET_ACCESS_KEY")
``` 

You might still see the following error:
```elixir
** (UndefinedFunctionError) function false.post/4 is undefined (module false is not available)
```

This is because Swoosh needs an API client to send email. In dev.exs it is set to false and you will have to enable it. Swoosh supports both Hackney and Finch out of box. And you will have to add any one of them as dependency in your `mix.exs` file.

In my app, I was using Finch. In my `application.ex` file Finch was started with the name `ExampleApp.Finch` - therefore, I had to also provide the `finch_name` as a configuration parameter.

```elixir
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: ExampleApp.Finch
```
