- Email DIY
The Benefits of Email Automation
Today’s post is written by Peter Clark, CEO of userfox ( now adroll ), an awesome new startup that is changing the way businesses communicate with their customers via email. They just launched a few weeks ago as you may have seen on Hacker News. In today’s post, Peter discusses what userfox does, how they’ve architected their app and a little bit about how they are using Mailgun, including the code to do it! Enjoy.
Hi, I’m Peter, CEO of userfox. userfox helps companies send better, more effective, welcome emails. Today, most businesses welcome new customers with a singular “welcome to my product!” email.
The problem with that is people are busy. You forget that you signed up for services, you only remember services you need or love, and that generally doesn’t happen the second you register.
So userfox sends a sequence of emails: when you register, a few days later, a week later, later in the month, and so on. The industry calls this a “drip” sequence. These emails contain cool tips and tricks about your product, anecdotes about who your customers are and why they love you – and so on.
We do this really simply. In fact, its much faster to integrate userfox with your application than to send your one crappy welcome email. It’s a no brainer, right? simply paste a singular snippet of javascript into your footer – and voila.
Framework: Ruby on Rails
Email automation & infrastructure: Mailgun
Database: MongoHQ for MongoDB
Testing: Citrus
We’re an email marketing company. We’re not an infrastructure company, so we rely on Mailgun to do stuff that otherwise we’d have to build. Mailgun delivers all of our customers’ emails. The Analytics API of Mailgun powers the userfox analytics. Why should we re-create the wheel with this stuff, when Mailgun does such a rad job? Besides, have you tried managing an email server? Mailgun does God’s work….
Our basic implementation using Mailgun looks like this. We build the message data together:
data = {:to => email, :from => get_from(trigger), :subject => get_subject(info, email,
trigger), :text => "#{text}", :html => "#{html}", "h:X-Mailgun-Variables" => "{"id": "" + id + ""}"}
And then queue it into a job via a REST post. Mailgun allows sending via SMTP but we prefer the flexibility and speed that comes with using the API. Our post looks like this.
RestClient.post Userfox::Application.config.mailgun_endpoint + '/' + domain + '/messages', data, :Authorization => Userfox::Application.config.mailgun_auth {
|response, request, result|
return response
}
Mailgun is really powerful when it comes to sending messages. But we also run all our analytics off of Mailgun. When a message is sent we want to know that it was delivered and what happened to it. Was it opened, clicked, reported as spam? Did the user unsubscribe (of course, this would never happen)? All this data can be sent to your app with webhooks. For instance, if you wanted to post to your database when a user clicks on a link you could do this:
require 'openssl'
def verify(api_key, token, timestamp, signature)
return signature == OpenSSL::HMAC.hexdigest(
OpenSSL::Digest::Digest.new('sha256'),
api_key,
'%s%s' % [timestamp, token])
end
class PostsController < ApplicationController
def api_key
"key-6mlhwmhnnqvvpocy17ji7qor3bihh566"
end
# GET /posts
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
end
end
# POST /posts
def create
if verify(api_key, params[:token], params[:timestamp], params[:signature])
user, event = params[:recipient], params[:event]
if event = 'clicked'
link = params[:url]
@post = Post.new(:name => "Name", :title => "Title",
:content => "#{user} clicked on #{link}").save
end
end
render :text => "OK"
end
end
This would tell you that a user has clicked on an email and give you information about who clicked it. You can do this for clicks, opens, unsubscribes, spam complaints, bounces, failures, and deliveries.
If you’ve got a business that needs to communicate with customers, give userfox a try. We’ve done the hard work for you.
Last updated on September 16, 2020
The Benefits of Email Automation
Mailgun Just Got Better For Client Management
Understanding DKIM: How It Works and Why It's Necessary
Preparing Your Email Infrastructure Correctly
COVID-19 Email Communications Dos and Don’ts
What is Transactional Email? The Basics
How Do Users on G2 Rate Mailgun?
Building the Best Email Experience for Creators - Flipsnack’s Story
Mailgun Is Now Part Of GitHub’s Student Developer Pack
Mailgun Is Now Part Of GitHub’s Student Developer Pack
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.