Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 您只能使用ActionMailer smtp_设置中指定的用户名发送电子邮件吗?_Ruby On Rails_Actionmailer - Fatal编程技术网

Ruby on rails 您只能使用ActionMailer smtp_设置中指定的用户名发送电子邮件吗?

Ruby on rails 您只能使用ActionMailer smtp_设置中指定的用户名发送电子邮件吗?,ruby-on-rails,actionmailer,Ruby On Rails,Actionmailer,在ActionMailer配置文件中,我有以下内容: ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "mail.foo.com", :port => 25, :domain => "foo.com", :authentication => :email, :user_name => "no-reply@foo.

在ActionMailer配置文件中,我有以下内容:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "mail.foo.com",
  :port => 25,
  :domain => "foo.com",
  :authentication => :email,
  :user_name => "no-reply@foo.com",
  :password => "foo1234567"
}
使用此配置,我只能从
no发送电子邮件-reply@foo.com
电子邮件地址?如果有,有没有办法从其他地址发送电子邮件?我的ActionMailer类中有以下内容:

class Notifications < ActionMailer::Base

  def answered_question(faq)
    subject       'Your question has been answered'
    recipients    faq.email
    from          'Foo <no-reply@foo.com>'
    sent_on       Time.now
    content_type  "text/html"
    body          :faq => faq
  end


  def completed_order(order)
    subject        'Your order has been completed'
    recipients     order.email                                       
    from           'Foo <registrations@foo.com>'
    sent_on        Time.now
    content_type   "text/html"
    body           :order => order
  end
end
类通知faq
终止
def已完成订单(订单)
主题“您的订单已完成”
收件人订单。电子邮件
来自“Foo”
现在就准时送你
内容类型为“文本/html”
正文:顺序=>顺序
终止
终止
在开发过程中,一切正常,但在生产过程中,
已完成的订单
电子邮件没有发出


谢谢。

我想这更像是一个SMTP问题,而不是ActionMailer。有些SMTP不需要用户名/密码来发送邮件,因此您可以根据需要设置发件人地址


也就是说,由于您在向SMTP服务器发送发件人地址不同于用于身份验证的发件人地址的邮件时遇到问题,我猜SMTP框上有一个限制,只有发件人地址与身份验证UID匹配时才允许发送邮件。

是的,这是服务器配置问题。谢谢