RailsCasts Pro episodes are now free!

Learn more or hide this

ricardofressa's Profile

GitHub User: ricardofressa

Comments by

Avatar

require 'development_mail_interceptor'

Avatar

Hello, I'm using an interceptor to the User when registering on my site it receives a confirmation e-mail and I also know that a User has been registered .. S'p that only I am getting the mail, the User does not receive ...

Can anyone help me?

app/controllers/contatos_controller.rb
view plaincopy to clipboardprint?
ContatoMailer.contato_confirmation(@contato).deliver

no meu
config/initializers/setup_mail.rb
view plaincopy to clipboardprint?
require 'development_mail_interceptor'

ActionMailer::Base.smtp_settings = {

:address => "smtp.gmail.com",

:port => 587,

:domain => "localhost:3000",

:user_name => "usuario",

:password => "secret",

:authentication => "plain",

:enable_starttls_auto => true

}

Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

no meu
lib/development_mail_interceptor.rb
view plaincopy to clipboardprint?
class DevelopmentMailInterceptor

def self.delivering_email(message)

message.subject = "#{message.to} #{message.subject}"

message.to = "admin@admin.com"

end

end

no meu app/mailers/contato_mailer.rb
view plaincopy to clipboardprint?
class ContatoMailer < ActionMailer::Base

default :from => "admin@admin.com"

def contato_confirmation(contato)

@contato = contato

mail(:to => "#{contato.nome} <#{contato.email}>", :subject => "Confirma