Rails 3 Net :: SMTPAuthenticationError(500无法识别的命令)

时间:2013-05-23 07:45:14

标签: ruby-on-rails-3 email actionmailer

从实时服务器发送电子邮件时

如果我使用gmail帐户配置smtp设置,则会成功发送邮件,

config.action_mailer.default_url_options = { :host => 'myhostip' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
  :address=> "mail.gmail.com",
  :port=> 587,
  :authentication=> "plain",
  :enable_starttls_auto=> false,
  :user_name=> "mymail@gmail.com",
  :password=> "password"
}

如果我使用我的服务器详细信息配置smtp设置它不发送邮件,而是抛出错误

Net :: SMTPAuthenticationError(500无法识别的命令)

在从设备发送用户确认电子邮件时触发此操作。

config.action_mailer.default_url_options = { :host => 'myhostip' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
  :address=> "mail.mydomain.com",
  :port=> 587,
  :domain=> "mydomain.com",
  :authentication=> "plain",
  :enable_starttls_auto=> false,
  :user_name=> "test@mydomain.com",
  :password=> "pwd"
}

1 个答案:

答案 0 :(得分:0)

您已使用ActionMaliler :: Base而不是config

   ActionMailer::Base.smtp_settings   #try this

  config.action_mailer.smtp_settings   #instead of  this

将您的smtp代码更改为以下内容。它现在应该工作。

      ActionMailer::Base.smtp_settings = {
         :address        => 'path_to_address_specified_by_my_hoster',
         :port           => 25,
         :domain         => 'my_domain.com',
         :authentication => :plain,
         :user_name      => 'signup@my_domain.com',
         :password       => 'password'
          }