class EmailProcessor
  def initialize(email)
    @email = email
  end

  def process
    # all of your application-specific code here - creating models,
    # processing reports, etc

    # here's an example of model creation
    newsletter = Newsletter.find_by_email(@email.from[:email])

  end
end

class EmailProcessor
  def initialize(email)
    @email = email
  end

  def process
    newsletter = Newsletter.find_by_email(@email.from[:email])
    Email.create(
      newsletter_id: newsletter.id,
      to: to,
      from: from,
      subject: subject,
      body: body,
      raw_text: raw_text,
      raw_html: raw_html,
      raw_body: raw_body,
      attachments: attachments,
      headers: headers,
      raw_headers: raw_headers
    )
  end
end

Save the running of email creator
Save the running of email creator
