Giter VIP home page Giter VIP logo

Comments (4)

riverrun avatar riverrun commented on August 16, 2024

I'll try and find out more about the current options for sending emails and get back to you.

from openmaize.

jsjohnst avatar jsjohnst commented on August 16, 2024

I was able to get this up and running using thoughtbot/bamboo. I'll try and submit a pull request with a sample this week if I get a chance, but here is the gist of it:

  • Changes in lib/my_app/mailer.ex
defmodule MyApp.Mailer do
  use Bamboo.Mailer, otp_app: :my_app

  @moduledoc """
  A module for sending emails.
  These functions are used for email confirmation and password resetting.
  """

  @doc """
  An email with a confirmation link in it.
  This function is called by the `create` function in the user_controller.
  It should send an email with the confirmation link to the user.
  """
  def ask_confirm(email, link) do
    confirm_url = "https://example.com/sessions/confirm_email?#{link}"
    MyApp.Email.email_validation(email, confirm_url) |> deliver_now
  end
end
  • Code inside web/email.ex
defmodule MyApp.Email do
  use Bamboo.Phoenix, view: MyApp.EmailView

  def email_validation(email, link) do
    base_email
    |> to(email)
    |> subject("MyApp: New Account Validation")
    |> assign(:link, link)
    |> render(:email_validation)
  end

  defp base_email do
    new_email
    |> from("MyApp <[email protected]>")
    |> put_layout({MyApp.LayoutView, :email})
  end
end

Other than the above, I just basically followed the documentation from Bamboo.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

That looks cool.
When it's ready, just submit the PR.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

We now have a basic example here, and there are references to it in the wiki.

from openmaize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.