aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-17 22:32:05 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-17 22:32:05 -0700
commit65a6d525c6ce36acefd4b1918bbc5f14132e7810 (patch)
treec02971982bb4dd89df121288bea38292891f12c4 /app
parentdd55bf66d27ce59405e7c1487f2f6edc61934dba (diff)
downloadrails-65a6d525c6ce36acefd4b1918bbc5f14132e7810.tar.gz
rails-65a6d525c6ce36acefd4b1918bbc5f14132e7810.tar.bz2
rails-65a6d525c6ce36acefd4b1918bbc5f14132e7810.zip
Add basic, unauthenticated inbound emails controller
Diffstat (limited to 'app')
-rw-r--r--app/controllers/action_mailroom/inbound_emails_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/action_mailroom/inbound_emails_controller.rb b/app/controllers/action_mailroom/inbound_emails_controller.rb
new file mode 100644
index 0000000000..0c74d4b29a
--- /dev/null
+++ b/app/controllers/action_mailroom/inbound_emails_controller.rb
@@ -0,0 +1,14 @@
+class ActionMailroom::InboundEmailsController < ActionController::Base
+ skip_forgery_protection
+ before_action :require_rfc822_message
+
+ def create
+ ActionMailroom::InboundEmail.create!(raw_email: params[:message])
+ head :created
+ end
+
+ private
+ def require_rfc822_message
+ head :unsupported_media_type unless params.require(:message).content_type == 'message/rfc822'
+ end
+end