目前,我们允许用户发送电子邮件,而不会看到彼此的实际电子邮件地址(双盲),这样他们就可以发送电子邮件username@parse.example.com
,效果很好。
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
对象而不是提取其内容,检查它是否是多部分等?