Add custom mailer for one-off emails
This commit is contained in:
parent
b1a0268e6b
commit
fb3b9af3e5
@ -1,4 +1,3 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout 'mailer'
|
||||
end
|
||||
|
23
app/mailers/custom_mailer.rb
Normal file
23
app/mailers/custom_mailer.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# A custom mailer that can be used from the Rails console for one-off emails
|
||||
# today, and later connected from an admin panel mailing page.
|
||||
#
|
||||
# Assign any template variables you want to use:
|
||||
#
|
||||
# user = User.first
|
||||
#
|
||||
# Create the email body from a custom email template file:
|
||||
#
|
||||
# body = ERB.new(File.read('./tmp/mailer-1.txt.erb')).result binding
|
||||
#
|
||||
# Send email via Sidekiq:
|
||||
#
|
||||
# CustomMailer.with(user: u, subject: "Important announcement", body: body).custom_message.deliver_later
|
||||
#
|
||||
class CustomMailer < ApplicationMailer
|
||||
def custom_message
|
||||
@user = params[:user]
|
||||
@subject = params[:subject]
|
||||
@body = params[:body]
|
||||
mail(to: @user.email, subject: @subject)
|
||||
end
|
||||
end
|
1
app/views/custom_mailer/custom_message.text.erb
Normal file
1
app/views/custom_mailer/custom_message.text.erb
Normal file
@ -0,0 +1 @@
|
||||
<%= @body %>
|
@ -2,9 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
<style></style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user