Skip to content

Latest commit

 

History

History

inbound

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

This helper is a stand alone module to help get you started consuming and processing Inbound Parse data.

Table of Contents

Installation

In addition to the installation instructions in the main readme, you must also add sinatra to your Gemfile:

gem 'sinatra', '>= 1.4.7', '< 3'

Quick Start for Local Testing with Sample Data

git clone https://github.com/sendgrid/sendgrid-ruby.git
cd sendgrid-ruby
bundle install

Run the Inbound Parse listener in your terminal:

rackup

In another terminal, run the test data sender:

cd [path to sendgrid-ruby]
bundle install
ruby ./lib/sendgrid/helpers/inbound/send.rb ./lib/sendgrid/helpers/inbound/sample_data/default_data.txt

More sample data can be found here.

View the results in the first terminal.

Quick Start for Local Testing with Real Data

Setup your MX records. Depending on your domain name host, you may need to wait up to 48 hours for the settings to propagate.

Run the Inbound Parse listener in your terminal:

git clone https://github.com/sendgrid/sendgrid-ruby.git
cd sendgrid-ruby
bundle install
rackup

In another terminal, use ngrok to allow external access to your machine:

ngrok http 9292

Update your Twilio SendGrid Incoming Parse settings: Settings Page | Docs

  • For the HOSTNAME field, use the domain that you changed the MX records (e.g. inbound.yourdomain.com)
  • For the URL field, use the URL generated by ngrok + /inbound, e.g http://XXXXXXX.ngrok.io/inbound

Next, send an email to [anything]@inbound.yourdomain.com, then look at the terminal where you started the Inbound Parse listener.

Code Walkthrough

app.rb

This module runs a Sinatra server, that by default (you can change those settings here), listens for POSTs on http://localhost:9292. When the server receives the POST, it parses and prints the key/value data.

config.yml

This module loads application environment variables (located in config.yml).

send.rb & /sample_data

This module is used to send sample test data. It is useful for testing and development, particularly while you wait for your MX records to propagate.

Contributing

If you would like to contribute to this project, please see our contributing guide. Thanks!