Is it worth the time and effort to create a feature on our rails website to send emails to our customer database once a week, or is MailChimp the almighty One to use to send weekly newsletters to thousands of people? If we used our rails application could SenderGrid or some other feature be an option for our newsletter?
We currently use Mailchimp and we love it but the owner of the company wants the website to do everything for us in one simple place.
Thank you for your feedback!
wants the website to do everything for us in one simple place.
In that case, it's not a question of "Mailchimp or bust", it's a question of abstraction.
Specifically, the owner will probably want a central "dashboard" on his web dashboard (kind of like how CRM works), from which he'll be able to see how many members, emails etc have been sent out.
As such, I'd endeavour to use Mandrill and collate the data in the app, like this:
#app/models/user.rb
class User < ActiveRecord::Base
has_many :mailouts
has_many :newsletters, through: :mailouts
end
#app/models/mailout.rb
class Mailout < ActiveRecord::Base
#columns id | user_id | newsletter_id | created_at | updated_at | sent_at | received_at
belongs_to :user
belongs_to :newsletter
end
#app/models/newsletter.rb
class Newsletter < ActiveRecord::Base
#columns id | title | body | created_at | updated_at
has_many :mailouts
has_many :users, through: :mailouts
after_create :set_mailouts
private
def set_mailouts
User.find_each do |user|
self.mailouts.create(user: user)
end
end
end
This would give you the ability to use the following:
#app/controllers/newsletters_controller.rb
class NewslettersController < ApplicationController
def new
@newsletter = Newsletter.new
end
def create
@newsletter = Newsletter.new newsletter_params
@newsletter.save
end
end
Quite inefficient with the after_create
, but nonetheless it shows that you can then have a rake task which would do something like this:
@newsletter = Newsletter.find x
@newsletter.mailouts.each do |mailout|
# send mailout to mandrill
end
Something important to remember is that Mandrill and SendGrid are infrastructure applications. Mailchimp itself provides UI functionality on top of the Mandrill infrastructure.
If you were looking to use the likes of Mailchimp, what you'd probably end up doing is sending the user list to Mailchimp each week, allowing you to send newsletters through their system.
Creating your own functionality & linking to Mandrill will only change your implementation by giving you the ability to manage the data on your own application. Just something to remember when thinking about the structure.