Skip to content

Instantly share code, notes, and snippets.

@novohispano
Last active September 1, 2015 14:32
Show Gist options
  • Save novohispano/1b1c1ed8ae933e51eac1 to your computer and use it in GitHub Desktop.
Save novohispano/1b1c1ed8ae933e51eac1 to your computer and use it in GitHub Desktop.
module Emailery
class Application < Rails::Application
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.mandrillapp.com',
port: 587,
domain: 'example.com',
user_name: '[email protected]',
password: 'ZNrasQmPJPybqX_gsihNdQ',
authentication: 'plain',
enable_starttls_auto: true
}
config.active_record.raise_in_transactional_callbacks = true
end
end
class NotificationsController < ApplicationController
def show
end
def create
NotificationsMailer.contact(email_params).deliver_now
redirect_to :back, notice: "Your email was sent."
end
private
def email_params
params.permit(:name, :email, :message)
end
end
class NotificationsMailer < ApplicationMailer
def contact(email_params)
@message = email_params[:message]
mail(
to: email_params[:email],
subject: "Mensaje de #{email_params[:name]}",
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment