honungsburk
Hi!
I’m building a small internal service to handle emails (it is not a webserver) and for this I have choosen Swoosh. Now I am trying to setup the mailbox preview and I want to use as few dependencies and as minimal setup as possible. Idealy, I would not even need to include it in the production environment but only in dev. What is hte minimal setup to make the preview work? Do I need to use pheonix as a dependency or is plug enough?
This is what I am currently trying:
config:
config :muninn, Phoenix.Endpoint,
url: [host: "localhost"],
render_errors: [formats: [html: Phoenix.Template.HTML]],
pubsub_server: Muninn.PubSub,
adapter: Bandit.PhoenixAdapter,
live_view: [signing_salt: "some_salt"]
application:
defmodule Muninn.Application do
@moduledoc """
Application module for Muninn.
"""
use Application
require Logger
@impl true
def start(_type, _args) do
# Oban.Telemetry.attach_default_logger(
# level: Application.get_env(:logger, :level),
# encode: true
# )
children = [
Muninn.Repo,
{Oban, Application.fetch_env!(:muninn, Oban)}
]
children =
if Application.get_env(:muninn, :email_preview) do
# children ++ [{Phoenix.Endpoint, []}]
children ++
[
# {Plug.Cowboy, scheme: :http, plug: Muninn.Router, options: [port: 4000]}
{Phoenix.PubSub, name: Muninn.PubSub},
# Start to serve requests, typically the last entry
Muninn.Endpoint
]
end
Supervisor.start_link(children, strategy: :one_for_one)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
Muninn.Endpoint.config_change(changed, removed)
:ok
end
end
Endpoint:
defmodule Muninn.Endpoint do
use Phoenix.Endpoint, otp_app: :runar
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_muninn_key",
signing_salt: "C6nzbDmG",
same_site: "Lax"
]
socket("/live", Phoenix.LiveView.Socket,
websocket: [connect_info: [:peer_data, session: @session_options]],
longpoll: [connect_info: [:peer_data, session: @session_options]]
)
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phx.digest
# when deploying your static files in production.
plug(Plug.Static,
at: "/",
from: :muninn,
gzip: false,
only: ~w(assets fonts images favicon.ico robots.txt manifest.json)
)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
plug(Phoenix.LiveReloader)
plug(Phoenix.CodeReloader)
# plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :muninn)
end
plug(Plug.RequestId)
# plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
)
plug(Plug.MethodOverride)
plug(Plug.Head)
plug(Plug.Session, @session_options)
plug(Muninn.Router)
end
router file:
defmodule Muninn.Router do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveReloader
pipeline :browser do
plug(:accepts, ["html"])
plug(:fetch_session)
if Mix.env() == :dev do
plug(:fetch_live_reload)
end
end
scope "/dev" do
pipe_through(:browser)
forward("/mailbox", Plug.Swoosh.MailboxPreview,
csp_nonce_assign_key: %{script: :script_csp_nonce, style: :style_csp_nonce}
)
end
end
But I’m getting this error:
error: undefined function fetch_live_reload/2 (expected Muninn.Router to define such a function or for it to be imported, but none are available)
└─ deps/phoenix/lib/phoenix/router.ex: Muninn.Router.browser/2
```
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
honungsburk
Got it working by following the instructions in the README: GitHub - swoosh/swoosh: Compose, deliver and test your emails easily in Elixir · GitHub