Sha256: 240726d8fc94677e8713f72fd65ab9d65d6a675e90676fa18f9c493762c0935e

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

class Rails::Conductor::ActionMailbox::InboundEmailsController < Rails::Conductor::BaseController
  def index
    @inbound_emails = ActionMailbox::InboundEmail.order(created_at: :desc)
  end

  def new
  end

  def show
    @inbound_email = ActionMailbox::InboundEmail.find(params[:id])
  end

  def create
    inbound_email = create_inbound_email(new_mail)
    redirect_to main_app.rails_conductor_inbound_email_url(inbound_email)
  end

  private
    def new_mail
      Mail.new params.require(:mail).permit(:from, :to, :cc, :bcc, :in_reply_to, :subject, :body).to_h
    end

    def create_inbound_email(mail)
      ActionMailbox::InboundEmail.create! raw_email: \
        { io: StringIO.new(mail.to_s), filename: 'inbound.eml', content_type: 'message/rfc822', identify: false }
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actionmailbox-0.1.0 app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb