Class: MailSpy::SendgridController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MailSpy::SendgridController
- Defined in:
- app/controllers/mail_spy/sendgrid_controller.rb
Instance Method Summary collapse
-
#notification ⇒ Object
Parses a notification from the sendgrid system.
Instance Method Details
#notification ⇒ Object
Parses a notification from the sendgrid system
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/mail_spy/sendgrid_controller.rb', line 5 def notification #Must be passed in via SendGrids SMTP API Headers email_id = params['eid'] return head 400 if email_id.blank? || params[:event].blank? #Send grid event name event_action = "sendgrid-#{params[:event]}" case params[:event] when 'bounce', 'dropped' MailSpy.track_action(email_id, event_action, {:reason => params[:reason]}) when 'click' MailSpy.track_action(email_id, event_action, {:url => params[:url]}) when 'deferred', 'delivered', 'processed', 'open', 'spamreport', 'unsubscribe' MailSpy.track_action(email_id, event_action) end head :ok end |