We're currently letting users email each other without seeing each other's actual email addresses (double blind) by letting them send emails to username@parse.example.com
which works great.
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
Is it possible to forward the whole mail
object instead of extracting its contents, checking if it is multipart etc?