Parsing Every Contact into a Daily Email


August 15, 2013
Written by
SendGrid Team
Contributor
Opinions expressed by Twilio contributors are their own

Parsing Every Contact into a Daily Email

In a previous blog post, I showed you how to remember people's names with a digestible daily email. I've been using the approach daily.

It has been helpful but has had one big downside: it requires me to make an API call by hand every time I want to add a person to the database. This is tedious. Let's change that by automating it.

SendGrid's Parse API can help us here.

The Approach

The majority of people's names I want to remember are people I have interacted with over email. Likely I met them in person, followed up with them over email, and might run into them again in my travels.

So let's forward all our emails to SendGrid's Parse API, pull out the email addresses from the contents of the email, and save that to our database. Now our database of people's names will automatically grow as our network grows.

Setup the MX records

To use the Parse API, we must add SendGrid's MX Record to a web domain we own. This will allow us to forward all emails to SendGrid's Parse API. Since it must take over email for an entire record, it's a good idea to use a sub-domain.

Go to your domain's DNS dashboard and add the MX record m.yourdomain.com with the value of mx.sendgrid.net.

visage-grid-part-2-1

Next, setup the SendGrid Parse API. Go to http://sendgrid.com/developer/reply. Set your hostname to m.yourdomain.com and set your url as https://yoursubdomain.herokuapp.com/emails/parse.

visage-grid-part-2-2

visage-grid-part-2-3

Now you can send an email to email@m.yourdomain.com, and SendGrid's Parse API will receive it, and make a POST request to https://yoursubdomain.herokuapp.com/emails/parse.

Awesome. Now, we can write the code to parse that incoming email data.

The Code

In app.js add the following code.



In the code above, we are setting up a route to catch the incoming email at /emails/parse. Then we get an array of email addresses out of that email. Finally, we add those emails to our database.

We're almost there. The final step is to forward all our incoming emails.

Forward Your Emails

Many email providers allow you to forward a copy of your email to another address. In GMail (my inbox of choice) go to Settings > Forwarding & POP/IMAP and add a forward address to email@m.yourdomain.com.

gmail

That's it. You are done. As you naturally use your email, this app will build a list of various people and email you about them - helping you to remember their names.

The source code is available on GitHub.

Recommended For You



Most Popular


Send With Confidence

Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.