Help us improve
Share bugs, ideas, or general feedback.
From majestic-rails
Creates or refactors Rails Action Mailer emails using 7.1+ conventions, parameterized mailers, preview workflows, background delivery, I18n, attachments, and RSpec tests.
npx claudepluginhub majesticlabs-dev/majestic-marketplace --plugin majestic-railsHow this skill is triggered — by the user, by Claude, or both
Slash command
/majestic-rails:action-mailer-coderThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
```ruby
Implements Rails ActionMailer for async email delivery via SolidQueue, with HTML/text templates, previews, testing, layouts, and attachments. Use for transactional and notification emails.
React Email component patterns for building responsive email templates using JSX, component composition, and preview servers. Use when creating reusable email components, building responsive templates, setting up email preview environments, or integrating React Email with Resend for dynamic email content.
Build responsive email templates with MJML in .NET apps using Mjml.Net. Compiles to cross-client HTML for Outlook, Gmail, Apple Mail with rendering and variables.
Share bugs, ideas, or general feedback.
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
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
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("hello@example.com", @account.name)
end
end
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
# 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
def welcome
@user = params.fetch(:user)
I18n.with_locale(@user.locale) do
mail(to: @user.email, subject: t(".subject", name: @user.name))
end
end
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
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-Pattern | Problem | Solution |
|---|---|---|
| One mailer per email | Hard to navigate | Group related emails |
Skipping .with() | Implicit dependencies | Use parameterized mailers |
deliver_now | Blocks request | Use deliver_later |
| Missing previews | Can't visually test | Create preview classes |
When creating mailers, provide: