在我的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
在开发过程中,一切正常,但在生产中,completed_order
电子邮件未发送出去。
感谢。
答案 0 :(得分:0)
我猜这更像是一个SMTP问题,它是ActionMailer。某些SMTP不需要用户名/密码发送外发邮件,因此您可以根据需要设置发件人地址。
也就是说,由于您遇到的问题是发送的邮件地址与您用于验证SMTP服务器的邮件地址不同,我猜测SMTP邮箱的限制只允许邮件发送到SMTP邮箱如果发件人地址与验证UID匹配,则发送。