# `PhoenixEmail`
[🔗](https://github.com/gabrielperales/phoenix-email/blob/v0.1.2/lib/phoenix_email.ex#L1)

Build emails with HEEx components. A port of
[react-email](https://react.email) for Phoenix.

Define emails as regular function components and render them to an HTML
string (or a plain text version for multipart emails):

    defmodule MyApp.Emails do
      use PhoenixEmail

      def welcome(assigns) do
        ~H"""
        <.email>
          <.head />
          <.preview>You're in — let's get you set up</.preview>
          <.body style="background-color:#ffffff;font-family:sans-serif">
            <.container>
              <.heading as="h1">Hello {@name}</.heading>
              <.text>Thanks for signing up.</.text>
              <.button href={@url} style="background-color:#5e6ad2;color:#fff;padding:12px 20px;border-radius:8px">
                Get started
              </.button>
              <.hr />
              <.link href="https://example.com">example.com</.link>
            </.container>
          </.body>
        </.email>
        """
      end
    end

    html = PhoenixEmail.render(&MyApp.Emails.welcome/1, %{name: "Ada", url: "https://example.com/start"})
    text = PhoenixEmail.render(&MyApp.Emails.welcome/1, %{name: "Ada", url: "https://example.com/start"}, plain_text: true)

`use PhoenixEmail` pulls in `Phoenix.Component` and imports all the
components from `PhoenixEmail.Components` (Phoenix's `link/1` is excluded
in favor of the email one).

# `render`

Renders an email to a string.

Accepts either the result of a `~H` template or a function component plus
its assigns. Returns the HTML prefixed with the XHTML 1.0 Transitional
doctype (the same one react-email emits).

## Options

  * `:plain_text` - when `true`, returns a plain text version of the email
    instead of HTML, for the `text/plain` part of multipart messages.

# `render`

Renders a function component to a string with the given assigns.

See `render/2` for the options.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
