2

我在我的 Rails 应用程序中使用邮箱 gem。以下是我的用户模型中的两种方法,它们是可消息的 -

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 方法时,我看到的电子邮件是有效的。

知道我哪里出错了吗?

4

1 回答 1

0

您收到错误消息:-“我们无法找到收件人域”

通过设置域 => 'gmail.com'

您应该指定

:domain =>  'your application name'   ( :domain => 'foo.com' or 'http://localhost:3000' )

还设置

config.action_mailer.delivery_method = :smtp

您根据生产,开发环境进行更改。

于 2013-07-18T09:07:51.833 回答