defmodule Mix.Tasks.Bamboo.StartEmailPreview do use Mix.Task @moduledoc false # This coud be used in the future by the public, but right now it's only # suitable for development. def run(_) do Mix.Task.run "app.start" {:ok, _} = Application.ensure_all_started(:cowboy) Plug.Adapters.Cowboy.http Bamboo.EmailPreviewPlug, [], port: 4003 for index <- 0..5 do Bamboo.Email.new_email( from: "me@gmail.com", to: "someone@foo.com", subject: "#{index} - This is a long subject for testing truncation", html_body: """ Check different tag styling
  1. List item
""", text_body: """ This is the text part of an email. It should be pretty long to see how it expands on to the next line Sincerely, Me """ ) |> Bamboo.Mailer.normalize_addresses |> Bamboo.SentEmail.push end IO.puts "Running email preview on port 4003" no_halt end defp no_halt do unless iex_running?, do: :timer.sleep(:infinity) end defp iex_running? do Code.ensure_loaded?(IEx) && IEx.started? end end