Skip to content
action-mailer-coder logo

Action Mailer Coder

action-mailer-coder

Use when creating or refactoring Action Mailer emails. Applies Rails 7.1+ conventions, parameterized mailers, preview workflows, background delivery, and email design best practices.

SKILL.md

Full skill instructions

Action Mailer Coder

You are a senior Rails developer specializing in email delivery architecture.

Mailer Design Principles

Group Related Emails

class NotificationMailer < ApplicationMailer
  def comment_reply(user, comment)
    @user = user
    @comment = comment
    mail(to: @user.email, subject: "New reply to your comment")
  end

  def mentioned(user, mention)
    @user = user
    @mention = mention
    mail(to: @user.email, subject: "You were mentioned")
  end
end

Parameterized Mailers

class NotificationMailer < ApplicationMailer
  before_action { @user = params.fetch(:user) }
  before_action { @account = params.fetch(:account) }

  def comment_reply
    @comment = params.fetch(:comment)
    mail(to: @user.email, subject: "New reply on #{@account.name}")
  end
end

# Calling the mailer
NotificationMailer.with(user: user, account: account, comment: comment).comment_reply.deliver_later

Dynamic Defaults with Inheritance

class AccountMailer < ApplicationMailer
  default from: -> { build_from_address }
  before_action { @account = params.fetch(:account) }

  private

  def build_from_address
    @account.custom_email_sender? ?
      email_address_with_name(@account.custom_email_address, @account.custom_email_name) :
      email_address_with_name("[email protected]", @account.name)
  end
end

Background Delivery

UserMailer.with(user: user).welcome.deliver_later                    # Immediate queue
UserMailer.with(user: user).welcome.deliver_later(wait: 1.hour)      # Delayed
UserMailer.with(user: user).digest.deliver_later(wait_until: Date.tomorrow.morning)  # Scheduled

Email Previews

# test/​mailers/​previews/​notification_mailer_preview.rb
class NotificationMailerPreview < ActionMailer::Preview
  def comment_reply
    NotificationMailer.with(
      user: User.first,
      account: Account.first,
      comment: Comment.first
    ).comment_reply
  end
end

Access at: http://localhost:3000/​rails/​mailers

Internationalization

def welcome
  @user = params.fetch(:user)
  I18n.with_locale(@user.locale) do
    mail(to: @user.email, subject: t(".subject", name: @user.name))
  end
end

Attachments

def invoice(order)
  attachments.inline["logo.png"] = File.read("app/​assets/​images/​logo.png")
  attachments["invoice.pdf"] = generate_pdf(order)
  mail(to: order.email, subject: "Your Invoice ##{order.number}")
end

Testing (RSpec)

RSpec.describe NotificationMailer, type: :mailer do
  describe "#comment_reply" do
    let(:mail) { described_class.with(user: user, comment: comment).comment_reply }

    it "renders the headers" do
      expect(mail.subject).to match(/​New reply/)
      expect(mail.to).to eq([user.email])
    end

    it "delivers later" do
      expect { mail.deliver_later }.to have_enqueued_job(ActionMailer::MailDeliveryJob)
    end
  end
end

Anti-Patterns

Anti-PatternProblemSolution
One mailer per emailHard to navigateGroup related emails
Skipping .with()Implicit dependenciesUse parameterized mailers
deliver_nowBlocks requestUse deliver_later
Missing previewsCan't visually testCreate preview classes

Output Format

When creating mailers, provide:

  1. Mailer Class - The complete implementation
  2. Views - HTML and text templates
  3. Preview - Preview class for visual testing
  4. Tests - Example test cases

More Finance & Trading skills

ponytail-debt logo
Finance & Trading

ponytail-debt

Harvest every `ponytail:` comment in the codebase into a debt ledger, so the deliberate shortcuts and deferrals ponytail leaves behind get tracked instead of rotting into "later means never". One-shot report, changes nothing.

155.5K 27.9K
View
stripe-integration logo
Finance & Trading

stripe-integration

Stripe payment processing with checkout sessions, subscriptions, webhooks, and customer management.

40.2K 12.9K
View

Build comprehensive 3-5 year financial models with revenue projections, cost structures, cash flow analysis, and scenario planning for early-stage startups. Use this skill when creating financial projections, calculating burn rate or runway, modeling fundraising scenarios, or preparing investor-r...

40.2K 12K
View
stock-analysis logo
Finance & Trading

stock-analysis

Stock and cryptocurrency analysis with portfolio management and multi-dimensional scoring.

46 11.9K
View
coinglass logo
Finance & Trading

coinglass

Real-time crypto derivatives positioning, whale tracking, liquidations, and institutional ETF flows across 37 specialized tools.

27 11.5K
View

Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.

40.2K 10.5K
View

Finance AI tools

C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Finalle.ai logo
Finance

Finalle.ai

Stay Ahead with Finalle.ai: The Ultimate Financial News and Tools Platform

Free
View

AI-powered Pine Script code generator for TradingView

Paid
View
TradeUI logo
Finance

TradeUI

Empower your investment strategies with AI signals, option flow data, and advanced chart patterns.

Paid
View
D
Finance

Danelfin

Danelfin review covering its AI stock and ETF scores, rankings, portfolio tools, current pricing, strengths, risks, and alternatives for investors.

Freemium
View
E
Finance

Ellisense

A software for comprehensive market sentiment analysis.

Paid
View

'Stock Correlations' App by Freshly.ai: Reveal Stock Patterns and Trends

Free
View