我在我的Rails应用程序中使用mailboxer gem。 以下是我的用户模型中的2个方法,它们是可以发信息的 -
def name
return :email
end
def mailboxer_email(object)
#Check if an email should be sent for that object
#if true
# mail(:to => :email, :subject => "Your Login credential")
return :email
#if false
#return nil
end
以下是我的development.rb文件中的smtp设置 -
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => 'gmail.com',
:user_name => 'address@gmail.com',
:password => 'mypassword',
:authentication => 'plain',
:enable_starttls_auto => true
}
但是在创建消息时,我收到以下错误 -
Completed 500 Internal Server Error in 22136ms
Net::SMTPFatalError (553-5.1.2 We weren't able to find the recipient domain. Please check for any
553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
553 5.1.2 or other punctuation after the recipient's email address. eg3sm14283691pac.1 - gsmtp
):
`app/controllers/conversations_controller.rb:12:in `create`'
我确定我将电子邮件发送到正确的电子邮件地址。此外,当我将调试器放入mailboxer_email方法时,我看到的电子邮件是有效的。
知道我哪里错了吗?
答案 0 :(得分:0)
您收到错误消息: - "我们无法找到收件人域名"
通过设置domain => ' gmail.com'
您应该指定
:domain => 'your application name' ( :domain => 'foo.com' or 'http://localhost:3000' )
还设置
config.action_mailer.delivery_method = :smtp
根据生产,开发环境改变。