SummaryThis episode is a prelude to ActiveJob and background processing. Learn how to send emails using an external mail service with Rails.
from = params[:contact][:from] subject = params[:contact][:subject] message = params[:contact][:message] ContactMailer.send_contact(from,subject,message).deliver_now
rails g mailer contact_mailer send_contact
def send_contact(from,subject,message) @from = from @subject = subject @message = message mail to: "[email protected]", subject: @subject end
def send_contact from = [email protected]' subject = 'Site Feedback' message = 'You should really have more episodes about different taco flavorings.' ContactMailer.send_contact(from,subject,message) end
<p>You have received a message from <%= @from %>.</p> <p><%= @message %></p>