面对行动邮件中的问题

时间:2011-08-25 17:52:37

标签: ruby-on-rails-3 actionmailer

在行动邮件中遇到问题。 我的邮件是

  def registration_confirmation(user)
    subject    "Password Reset Instructions"
    from        "sender_email_id@test.com"
    recipients  user.email
    content_type "text/html"
    body        "RESET your Password"
  end

邮件的设置为

require 'development_mail_interceptor'

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

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

我的控制器是UserMailer.registration_confirmation(@new_user).deliver

邮件不会发送到user.email,它总是发送到admin@domain.in

我正在使用mail-v 2.2.19和rails 3.0.9

请帮忙。

1 个答案:

答案 0 :(得分:1)

尝试添加此行(适用于我):

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

到您的registration_confirmation方法

def registration_confirmation(user)
    from        "sender_email_id@test.com"
    content_type "text/html"
    body        "RESET your Password"
    mail(:to => user.email, :subject => "Password Reset Instructions")
end