ActionMailer响应“501 5.5.4无效参数”
我正在使用Ruby 2.0.0上的Rails 4开发应用程序。 应用程序在Devise中注册后发送电子邮件。
这是发送电子邮件的代码:
应用程序/模型/ sponsor.rb:
after_create :send_email_to_admin private def send_email_to_admin AdminMailer.new_sponsor_email(self).deliver end
应用程序/邮寄者/ admin_mailer.rb
class AdminMailer < ActionMailer::Base default to: '**removed**' def new_sponsor_email(sponsor) @sponsor = sponsor p @sponsor mail(subject: "New Sponsor Registration") end end
这是从日志文件生成的电子邮件:
Sent mail to **removed** (725.5ms) Date: Mon, 02 Sep 2013 15:01:03 -0400 From: **removed** To: **removed** Message-ID: Subject: New Sponsor Registration Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a"; charset=UTF-8 Content-Transfer-Encoding: 7bit ----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit A new sponsor has signed up! ========================== ----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit A new sponsor has signed up!
----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a--
当我尝试通过创建赞助商来测试代码时,我只是得到了这个错误:
Net::SMTPSyntaxError in Devise::RegistrationsController#create 501 5.5.4 Invalid argument
我的理解是,这通常是因为电子邮件是无效的电子邮件,但我的所有电子邮件都非常简单,格式为name@domain.tld
和no-reply@domain.tld
。
问题似乎是我在smtp_settings中使用“域”。 当我删除它时,我能够从Mailgun和Gmail发送电子邮件