配置ActionMailer以使用1& 1 SMTP发送邮件

时间:2014-05-21 08:19:12

标签: ruby-on-rails email smtp sendmail actionmailer

我正在尝试将ActionMailer配置为使用SMTP服务器发送邮件1和1。我已经阅读了instructions provided by 1&1以及有关此主题的所有SO问题和答案,但我无法对其进行配置。

这是我的配置(在config/environments/development.rb中):

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {
    :address => "smtp.1and1.com",
    :domain => "1and1.com",
    :port      => "25",
    :authentication => :login,
    :user_name => 'MY_EMAIL@MY_DOMAIN.COM,
    :password  => 'MY_PASSWORD'
  }

这不起作用。其他我尝试不成功的事情:

  • port设为587
  • authentication设为:plain

这就是:当执行deliver方法时,它会挂起10秒左右,然后结束而不会显然失败,将其输出到日志中:

Sent mail to SOME_EMAIL@SOMEDOMAIN.COM (30041.5ms)

但我没有收到邮件。顺便说一句,使用gmail配置它有效,并且日志输出是相同的。

有没有人成功配置它?

编辑1:我再次检查了日志。我发现了这个:

[...] Net::SMTPAuthenticationError: 535 Authentication failure

编辑2:使用端口25,日志为:

[...] Timeout::Error: execution expired

编辑3 :使用:address => "auth.smtp.1and1.co.uk" 工作。这是1& 1问题吗?

2 个答案:

答案 0 :(得分:1)

这适合我:

config.action_mailer.smtp_settings = {
    :address => "smtp.1and1.com",
    :port      => 25,
    :authentication => 'plain',
    :user_name => 'MY_EMAIL@MY_DOMAIN.COM,
    :password  => 'MY_PASSWORD'
}

// SMTP CODE 535表示只是错误的用户名/密码。确保使用整个maila ddress作为用户名。

答案 1 :(得分:1)

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  address:              'auth.smtp.1and1.co.uk',
  domain:               '1and1.com',
  port:                 587,  
  authentication:       'login',
  user_name:            'email@domain.com',
  password:             'password',
  }

这对我有用,并确保配置默认

  

默认来自:“email@domain.com”

相关问题