是否可以在Action Mailer中转发邮件对象

问题描述

我们目前正在通过允许用户向[email protected]发送电子邮件,这使用户能够相互发送电子邮件而不会看到彼此的实际电子邮件地址(双盲)。

class ForwardsMailbox < ApplicationMailbox
  before_processing :ensure_users
 
  def process
    content = mail.multipart? ? mail.parts.first.body.decoded : mail.decoded
    UserMailer.with(sender: sender,recipient: recipient,subject: mail.subject,content: content).forward_email.deliver_later
  end
 
  private 
  def sender
    @sender ||= User.find_by(email: mail.from.first)
  end
  def recipient
    @recipient ||= User.find_by(username: mail.to.first.split('@').first)
  end
  def ensure_users
    bounce_with UserMailer.invalid_user(inbound_email) if sender.nil? or recipient.nil?
  end
end

是否可以转发整个mail对象,而不是提取其内容,检查它是否为多部分等?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)