2
我在Rails應用程序中使用郵箱寶石。 以下是我的用戶模型,它是messageable 2種方法 -Rails Mailboxer - 通過smtp發送電子郵件時找不到收件人域
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 => '[email protected]',
: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方法中時,我看到的電子郵件是有效的。
任何想法我錯了?
感謝您的回覆Gaurav。我試過了,但它仍然拋出了同樣的錯誤。 – Saurabh