# app/mailers/support_mailer.rb
#
# The Main Support Emailer
#
class SupportMailer < ApplicationMailer
# Generic mailer for Support form. Takes hash of params for processing.
# Hash can includes [:From] and [:Body]
#
def support_email(hash = {})
@input = hash
@subject = "Support request"
email = Rails.env == "development" ? "you@me.com" : "someone@you.com"
mail_params = {
to: email,
from: 'this_person@beats_me.com',
subject: @subject
}
mail(mail_params)
end
end
# app/controllers/yourController.rb
def support_email
params.each{|p| logger.info "\n\n#{p}\n\n"}
SupportMailer.support_email(params).deliver_now
flash[:notice] = "Support Request Sent<br />Thank you for your input"
redirect_to :root
end
# config/routes.rb
post 'support_email', to: 'yourController#support_email'