gpt4 book ai didi

ruby-on-rails - ActionMailer 响应 "501 5.5.4 Invalid argument"

转载 作者:太空宇宙 更新时间:2023-11-03 16:03:52 26 4
gpt4 key购买 nike

我正在使用 Ruby 2.0.0 上的 Rails 4 开发一个应用程序。在 Devise 中注册后,应用程序会发送一封电子邮件。

这是发送电子邮件的代码:

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

这是从日志文件生成的电子邮件:

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--

当我尝试通过创建赞助商来测试代码时,我收到了这个错误:

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

我的理解是,这通常是因为电子邮件是无效电子邮件,但我所有的电子邮件都非常简单,格式为 name@domain.tldno-reply @domain.tld.

最佳答案

问题似乎是我在 smtp_settings 中使用了“域”。当我删除它时,我能够从 Mailgun 和 Gmail 发送电子邮件

关于ruby-on-rails - ActionMailer 响应 "501 5.5.4 Invalid argument",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18579439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com