DOCS LLMs

Sending transactional emails

When you followed the quickstart, you configured your Amazon SES credentials to send transactional emails.

On top of that, your RailsFast app is configured to send beautiful transactional emails using the goodmail gem by default. So instead of sending boring, ugly, plaintext emails -- you send well-designed emails that look good on all email clients:

RailsFast beautiful transactional emails

Your user auth emails, payment-related emails, organization invitation emails, and an account-lifecycle email (account termination) come already configured and working out of the box.

You can view and edit all those emails:

  • app/mailers/devise_goodmailer.rb for devise-related emails (user authentication)
  • app/mailers/pay_goodmailer.rb for pay-related emails (payments & subscriptions)
  • app/mailers/organization_invitation_goodmailer.rb for team invitation emails
  • app/mailers/user_goodmailer.rb for account lifecycle emails

If you're adding a normal Rails mailer, use Goodmail's Action Mailer helper inside the mailer action:

class UserMailer < ApplicationMailer
  def welcome(user)
    @user = user

    goodmail_mail(to: @user.email, subject: "Welcome!") do
      h1 "Welcome aboard, #{@user.name}!"
      text "We're thrilled to have you join the community."
      button "Go to Dashboard", dashboard_url
      sign
    end
  end
end

For one-off emails outside a mailer class, you can also compose and deliver directly:

mail = Goodmail.compose(
  to: recipient.email,
  from: "'#{Goodmail.config.company_name} Support' <[email protected]>",
  subject: "Welcome!",
) do
  h1 "Welcome aboard, #{recipient.name}!"
  text "We're thrilled to have you join the community."
  button "Go to Dashboard", user_dashboard_url(recipient)
  sign
end

mail.deliver_now

You can customize all transactional emails however you want! Add animated GIFs, change the text, make new emails... make sure to read the goodmail gem docs to know everything that's possible.

If you don't like goodmail, or if you'd like to use your own email templates, you can still use Rails' ActionMailer -- goodmail is just an add-on, doesn't replace Action Mailer, you can keep writing emails with Action Mailer if that's what you like!