Rails邮件错误

时间:2014-09-12 13:17:22

标签: ruby-on-rails ruby-on-rails-3 smtp actionmailer mailer

这是我的邮件

def registration_confirmation(user)
            @user = user
            delivery_options = { user_name: "#{user.name}",
                                  password: "#{user.password}",
                                   address: "#{user.to}" }

            mail(        to: "#{user.name} <#{user.to}>", 
                       from: "#{user.from}", 
                    subject: "Registered",
    delivery_method_options: delivery_options)
end

这是我的配置

development:
  :address: smtp.gmail.com
  :port: 587
  :authentication: plain
  :enable_starttls_auto: true
  :openssl_verify_mode: 'none'

发出此错误

  

530-5.5.1需要验证。

了解更多信息

我如何解决它?

1 个答案:

答案 0 :(得分:-1)

如果您正确指定了gmail凭据:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {
                  :address        => "smtp.gmail.com",
                  :port           => 587,
                  :authentication => :plain,
                  :user_name      => "username@gmail.com",
                  :password       => "gmail password",
                  :openssl_verify_mode  => 'none'
} 

然后可能是gmail端的授权问题。浏览此链接https://accounts.google.com/DisplayUnlockCaptcha并允许身份验证。你完成了更多细节https://support.google.com/mail/answer/14257