【发布时间】:2025-12-28 08:10:06
【问题描述】:
问题:如何设置我的邮件程序/设计以允许“发件人”来自 current_user.email 而不是仅一封电子邮件?
说明:我已连接我的 rails 邮件程序以使用 Microsoft Exchange。一切正常,但我遇到的问题是电子邮件(development.rb、mailer 和 devise.rb)中的“发件人”必须相同才能使电子邮件发出。 我们的应用程序有不同的管理员用户,我们希望传出的电子邮件来自他们的电子邮件,而不是只有一个。
这是我设置 microsoft exchage 所遵循的链接。 "https://www.brownwebdesign.com/blog/connecting-rails-to-microsoft-exchange-smtp-email-server"
我已尝试使用 Devise Doc 设置邮件程序来指定我的 FROM,但仍然无法正常工作.. "https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer"
def confirmation_instructions(record, token, opts={})
headers["Custom-header"] = "Bar"
opts[:from] = 'my_custom_from@domain.com'
opts[:reply_to] = 'my_custom_from@domain.com'
super
end
我是初级开发人员,在更改邮件设置方面工作不多。 这是我的邮件。我的控制器将 current_user 带过来,并且记录正确。
class FeedbackMailer < ActionMailer::Base
default to: "JohnDoe@gmail.com"
def question_email(email, type, notes, current_user)
@user_email = current_user.email
logger.debug("Are you getting the email or what? # .
{@user_email.inspect}")
logger.debug("LOOKING FOR THE EMAIL #{email}")
@email = email
@type = type
@notes = notes
mail( from: "xxx@microsoft.com", subject:
"You have Feedback")
end
end
【问题讨论】:
标签: ruby-on-rails devise actionmailer