Skip to content

Instantly share code, notes, and snippets.

@Godoy
Created April 16, 2013 12:56
Show Gist options
  • Select an option

  • Save Godoy/5395675 to your computer and use it in GitHub Desktop.

Select an option

Save Godoy/5395675 to your computer and use it in GitHub Desktop.
Enviando e-mail com Action Mailer em Rails.
config.action_mailer.smtp_settings = {
:address => "mail.adrianogodoy.com",
:port => 587,
:domain => "adrianogodoy.com",
:user_name => "[email protected]",
:password => "senha",
:authentication => :login,
:enable_starttls_auto => false
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
class ContactController < ApplicationController
def create
....
NotificationsMailer.new_message(@message).deliver
....
end
end
<!-- /views/notifications_mailer/new_message.text.erb -->
Name: <%= @message.name %>
Email: <%= @message.email %>
Subject: <%= @message.subject %>
Body: <%= @message.body %>
#mailers/notifications_mailer.rb
class NotificationsMailer < ActionMailer::Base
default :from => "[email protected]"
default :to => "[email protected]"
def new_message(message)
@message = message
mail(:subject => "[Contato Titulo] #{message.name}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment