Anurag
Anurag

Reputation: 1016

facing problem in action mailer

facing problem in action mailer. my mailer is

  def registration_confirmation(user)
    subject    "Password Reset Instructions"
    from        "[email protected]"
    recipients  user.email
    content_type "text/html"
    body        "RESET your Password"
  end

Settings for mailer are

require 'development_mail_interceptor'

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "domain.in",
  :user_name            => "[email protected]",
  :password             => "PASSWORD",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = "localhost:3000"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

and my controller is UserMailer.registration_confirmation(@new_user).deliver

The mail is not going to the user.email , it is always going to [email protected]

I am using mail-v 2.2.19 and rails 3.0.9

please help.

Upvotes: 0

Views: 164

Answers (1)

Hishalv
Hishalv

Reputation: 3052

try adding this line(works for me):

mail(:to => user.email, :subject => "Password Reset Instructions")

to your registration_confirmation method

def registration_confirmation(user)
    from        "[email protected]"
    content_type "text/html"
    body        "RESET your Password"
    mail(:to => user.email, :subject => "Password Reset Instructions")
end

Upvotes: 1

Related Questions