我正在尝试向用户发送确认电子邮件。
但我得到以下错误:
Net::SMTPAuthenticationError (502 5.5.2 Error: command not recognized
production.rb 中的配置如下:
# Disable delivery errors, bad email addresses will be ignored
config.action_mailer.raise_delivery_errors = true
# set delivery method to :smtp, :sendmail or :test
config.action_mailer.delivery_method = :smtp
# these options are only needed if you choose smtp delivery
config.action_mailer.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'
}
我在托管服务提供商的用户配置文件中创建了一个邮箱,名为“signup@my_domain.com”
对于创建的邮箱,他们发给我的登录名和密码:
login = verbose_login
password = verbose_password
我没有完全理解 :user_name 的确切格式。
我应该使用
:user_name => "signup@my_domain.com"
或:
:user_name => "signup"
或:
:user_name => "verbose_login"
或者这个字段是特定于邮件服务器的,我必须请求托管服务提供商的支持?
:authentication => :plain 和 :login 之间有什么区别?
谢谢。
最佳答案
这很适合我:
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => 'my_nick@gmail.com',
:password => 'secret_password',
:authentication => 'login',
:enable_starttls_auto => true
}
更多信息 here
彼得
关于ruby-on-rails - Rails ActionMailer 中的 Net::SMTPAuthenticationError 502 5.5.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3373130/