Sendgrid + Sendgrid Toolkit is pretty awesome
Sendgrid’s a great way to send email from your app. They provide statistics, reliable delivery, and a fantastic XML/JSON API. If you’re using Ruby, I recommend checkout out Sendgrid Toolkit, which I just found out about.
Sendgrid Toolkit is pretty much a thin wrapper using jnunemaker’s HTTParty, which I haven’t heard about till now. HTTParty’s a pretty cool way to painlessly create an interface to a Web API.
Sendgrid Toolkit’s use of HTTParty makes adding functionality very easy. I added bounce retrieve and delete functionality by merely adding the small number of lines seen in the code sample.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SendgridToolkit | |
class Bounces < AbstractSendgridClient | |
def retrieve(options = {}) | |
options.each {|k,v| options[k] = 1 if k.to_s == 'date' && v == true} | |
api_post('bounces','get',options) | |
end | |
def delete(options = {}) | |
response = api_post('bounces','delete',options) | |
raise BounceEmailDoesNotExist if response['message'].include?('does not exist') | |
response | |
end | |
end | |
end |