If you have a domain with Namecheap and want to relay messages received on that domain to SendGrid so you can then process them as objects (for example via Griddler in a Rails app), read on.
SendGrid
We'll whitelabel your domain, then we'll return to set up an inbound parse.
Whitelabel
- Log in to your SendGrid account (or sign up, if you don't have one)
- Go to Settings
- Go to Whitelabels
- Click Add Domain
- Choose a subdomain, e.g. email
- Enter your domain, e.g. examplesite.com (no protocol)
- Allow Automated Security
- Click Save
This will need to be validated, after we've configured Namecheap and the DNS updates have propagated.
Namecheap
First, go to your advanced DNS settings. Steps below if needed.
- Log in to your Namecheap account
- Click Account
- Click Dashboard
- Select Manage for the domain you want to use
- Click Advanced DNS
You may already have some host records, for example a CNAME record for www and a URL Redirect Record for @. Either way, we can add some additional ones without conflict. Add the following records, replacing the X and # characters with your own details from SendGrid.
Type | Host | Value | TTL |
---|---|---|---|
CNAME Record | email. | X#######.XX###.sendgrid.net. | Automatic |
CNAME Record | s1._domainkey | s1.domainkey.X#######.XX###.sendgrid.net. | Automatic |
CNAME Record | s2._domainkey | s2.domainkey.X#######.XX###.sendgrid.net. | Automatic |
The full stop placement is essential.
Now we need to set an MX Record. Under Mail Settings select Custom MX and add the following record.
Type | Host | Mail Server | Priority | TTL |
---|---|---|---|---|
MX Record | @ | mx.sendgrid.net. | 10 | Automatic |
Note that here I'm relaying all email to SendGrid. This is not necessarily what you want to do.
Once you've added these records, it can take up to 48 hours for the changes to propagate. In my case it took about 2 minutes. For a quick check on whether you're there or not, you can use MxToolbox's MX Lookup.
Inbound Parse
Back in the SendGrid settings, make sure you validate the Whitelabel settings. If you don't get a nice green checkmark, either the settings in Namecheap and SendGrid are incorrect or you need to be patient for the DNS changes to propagate.
Once validated:
- Go to Settings
- Go to Inbound Parse
- Click Add Host & URL*
- Leave the subdomain empty
- For domain, select your whitelabelled domain
- As destination URL, choose the URL on your domain which is going to handle incoming emails, e.g.
http://www.examplesite.com/email_processor
Now repeat these steps again, but with www
for the subdomain.
Once done, you can test everything is working by sending an email to your domain. In SendGrid, this should then show up in the Activity Feed (Activity menu item).