Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created February 17, 2014 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choonkeat/9051139 to your computer and use it in GitHub Desktop.
Save choonkeat/9051139 to your computer and use it in GitHub Desktop.
# Add to config/routes.rb
# post 'incoming_emails' => 'incoming_emails#create'
require 'mail'
class IncomingEmailsController < ApplicationController
skip_before_filter :verify_authenticity_token, only: :create
def create
mail = Mail.new(params[:message])
# API for https://github.com/mikel/mail
mail.from # => ["sender@example.com"]
mail.to # => ["example@mail2webhook.com"]
mail.subject # => "Testing 1 2 3"
mail.parts # => [#<Mail::Part:70135193504060, Multipart: false, Headers: <Content-Type: text/plain; charset=ISO-8859-1>>,...]
mail.body # => #<Mail::Body:...>
render text: "OK"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment