ActionMailer responds with “501 5.5.4 Invalid argument”

∥☆過路亽.° 提交于 2019-12-10 22:24:38

问题


I'm working on an application with Rails 4 on Ruby 2.0.0. The application sends out an email after a registration in Devise.

This is the code that sends the email:

app/models/sponsor.rb:

after_create :send_email_to_admin

private

def send_email_to_admin
    AdminMailer.new_sponsor_email(self).deliver
end

app/mailers/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

And this is the generated email from the log file:

Sent mail to **removed** (725.5ms)
Date: Mon, 02 Sep 2013 15:01:03 -0400
From: **removed**
To: **removed**
Message-ID: <5224e06f4dddd_2e5a3fa0452dcfd874597@centaur.mail>
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

<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
  </head>
  <body>
    <h1>A new sponsor has signed up!</h1>
  </body>
</html>

----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a--

when I try to test the code by creating a sponsor, I just get this error:

Net::SMTPSyntaxError in Devise::RegistrationsController#create
501 5.5.4 Invalid argument

My understanding is that this is typically because the email is and invalid email, but all of my emails are very simple, in the format of name@domain.tld and no-reply@domain.tld.


回答1:


The issue seemed to be that I was using "domain" in my smtp_settings. When I removed that, I was able to send emails from both Mailgun and Gmail



来源:https://stackoverflow.com/questions/18579439/actionmailer-responds-with-501-5-5-4-invalid-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!