I’m trying to figure out the right way to add email functionality to my Rails project. Right now I have a few different options and I’m not sure which one to pick.
I already started setting up one approach where I added the gem, configured the settings, and was planning to use Active Job for background processing. But I stopped because I’m not confident this is the right path.
I’ve also read about using a Heroku addon which seems simpler and requires less custom code. My app already has Devise working so I don’t need emails for user authentication stuff.
I’m pretty confused about which direction to go. If anyone has experience with this or knows good tutorials, I’d really appreciate the help.
Also, someone mentioned to me that I shouldn’t send emails from ActiveRecord callbacks and should do it from controllers instead. Does that sound right to you?
One more thing - I want to be able to send bulk emails to all users for things like weekly updates and feature announcements. Would an email service API even be the right tool for this kind of mass mailing?
Your ActiveJob setup is solid - I’ve run it in production for two years with ActionMailer and it works great for transactional emails. Use SMTP with Postmark or Mailgun for good deliverability without getting locked into one vendor. Don’t send emails from ActiveRecord callbacks though. I made that mistake and when database rollbacks happened, users got confused about which emails they should’ve received. Handle it in controllers or service objects instead. For bulk emails, just use ConvertKit or Mailchimp. Transactional services hit you with rate limits and charge more for marketing stuff. You’ll also get way better analytics and unsubscribe tools.
I just went through this same decision and found a hybrid approach works best. For transactional stuff (order confirmations, password resets), stick with ActionMailer + Amazon SES. It’s cheap, reliable, and setup’s pretty simple. You’ll get solid delivery rates without spending much.
On callbacks - don’t send emails from ActiveRecord callbacks. I got burned when a payment failed and rolled back the transaction, but the welcome email was already queued. Now I handle email triggers in my service layer where I can control the flow better.
For bulk emails like newsletters, use a dedicated marketing platform. I went with ConvertKit since transactional services aren’t built for marketing and you’ll hit deliverability problems. Plus you get proper unsubscribe handling and better templates without building all that yourself.
heroku add-ons like sendgrid are super easy to use with rails. way better than dealing with smtp myself! but for bulk emails, i recommend mailchimp or something similar, since many transactional services limit the number you can send at once.