ArgumentError:发送消息需要 SMTP 收件人地址。设置消息 smtp_envelope_to、to、cc 或 bcc 地址

2024-02-27

我得到了一个带有以下邮件配置的 Rails 4 应用程序:

config.action_mailer.delivery_method = :smtp
  config.action_mailer.default_url_options = { host: 'myhost.com' }
  config.action_mailer.perform_deliveries = true

  config.action_mailer.smtp_settings = {
    :enable_starttls_auto => true,
    :address            => 'smtp.myhost.com',
    :port               => 587,
    :domain             => 'myhost.com',
    :authentication     => :login,
    :enable_starttls_auto => false,
    :tls                  => false,
    :openssl_verify_mode  => 'none',
    :ssl => false,
    :user_name          => "myusername",
    :password           => "mypassword"
  }

每次我尝试使用测试邮件程序设置发送邮件时:

class TestMailer < ActionMailer::Base

  default :from => "[email protected] /cdn-cgi/l/email-protection"

  def welcome_email
    mail(:to => "[email protected] /cdn-cgi/l/email-protection", :subject => "Test mail", :body => "Test mail body")
  end
end

TestMailer.welcome_email.deliver

我得到了这个异常:

ArgumentError:发送消息需要 SMTP 收件人地址。放 消息 smtp_envelope_to、to、cc 或 bcc 地址。

是否有可能我忘记设置一些东西? 我找不到“smtp_envelope_to”的配置选项


该错误消息与 SMTP 信封无关,而是与发件人有关:

发送邮件需要 SMTP 收件人地址

其余的只是一条通用消息。 你的某些东西[email protected] /cdn-cgi/l/email-protection不管用。 您使用真实的工作地址吗?如果没有,请尝试使用一个。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ArgumentError:发送消息需要 SMTP 收件人地址。设置消息 smtp_envelope_to、to、cc 或 bcc 地址 的相关文章

随机推荐