Last active
September 1, 2015 14:32
-
-
Save novohispano/1b1c1ed8ae933e51eac1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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