【问题标题】:ActionMailer with SMTP - Bad recipient address syntax带有 SMTP 的 ActionMailer - 错误的收件人地址语法
【发布时间】:2013-12-26 06:47:42
【问题描述】:

我的用户有这样格式的电子邮件:“-user-@domain.com”。 Mailgun 验证成功,但 Rails 无法向该地址发送电子邮件。我将 SMTP 与 Mandrill 一起使用。 这是错误信息:

/home/johnny/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/net/smtp.rb:948:in `check_response': 401 4.1.3 Bad recipient address syntax (Net::SMTPServerBusy)

你有什么想法吗?

提前致谢。

更新:

此示例代码(具有有效的 SMTP 配置)会引发错误:

#!/usr/bin/env ruby
require 'mail'

options = {
    address:      "smtp.mandrillapp.com",
    port:     587,
    domain:     "mydomain.com",
    authentication:   "login",
    user_name:    "myemail@mydomain.com",
    password:     "mypassword",
    enable_starttls_auto: false
}

Mail.defaults do
    delivery_method :smtp, options
end

Mail.deliver do
    from 'valid.email@domain.com'
    to "-test-@domain.com"
    subject 'Testing sendmail'
    body 'Testing sendmail'
end

【问题讨论】:

  • 展示一些示例代码怎么样?例如。邮件发送代码和/或 smtp 配置?
  • 代码和配置工作正常,该错误仅随该电子邮件引发。

标签: ruby-on-rails smtp actionmailer


【解决方案1】:

即使电子邮件地址中的起始破折号有效,由于命令行参数的限制,大多数邮件服务器也不接受此类电子邮件。

您可以尝试的快速解决方法是用尖括号括住电子邮件地址:

Mail.deliver do
  from 'valid.email@domain.com'
  to "<-test-@domain.com>"
  subject 'Testing sendmail'
  body 'Testing sendmail'
end

【讨论】:

  • 感谢您的建议,但仍然没有出现同样的错误。
  • 我担心这不是一个容易解决的任务,你可能不会。也许使用电子邮件别名可以解决问题,但您的用户应该为您提供一个。
  • 感谢@marzapower 的帮助。我会检查是否有其他方法解决它,否则我不得不放弃这种地址。
  • 我还有一些重要的事情要解决,所以我会在几天后回来......
猜你喜欢
  • 2017-06-08
  • 2017-04-30
  • 2011-01-27
  • 2015-02-16
  • 1970-01-01
  • 1970-01-01
  • 2015-10-31
  • 2018-08-04
  • 2020-08-23
相关资源
最近更新 更多