Reputation: 1531
I am running a rails app on heroku and would like to send an email to 160 users. This is the first time I am doing this so I would to very whether the method below will lead to a successful outcome.
Sendgrid is all sent up and I have a controller setup that executes the following:
@users = User.all
@users.each do |u|
Email.send_email(p).deliver
end
I am assuming that since the number of recipients is relatively low I would be able to get by without using delayed_job or some other background processing.
Upvotes: 1
Views: 321
Reputation: 13188
SendGrid actually makes it easy to send out emails without having to use a background worker. You can do it using the X-SMTPAPI header and setting an array of email addresses in the to
field. For example:
X-SMTPAPI: {
to: ["[email protected]", "[email protected]", "[email protected]"]
}
In this example, each of these three emails will receive a separate copy of the email. No background workers, no complexity.
There's a gem called sendgrid
that does a good job of adding some useful helpers to action mailer. Have a look at the "multiple recipients" section of the README
https://github.com/stephenb/sendgrid
Upvotes: 1
Reputation: 399
I would advise that you invest the time into some background processing, as this could potentially be a hit or miss, all depending on the emailing service.
Upvotes: 0