Skip to content

Instantly share code, notes, and snippets.

@nburkley
Last active December 30, 2019 11:14
Show Gist options
  • Save nburkley/d0f7d1b5b12fc9832404e7e28b42d02e to your computer and use it in GitHub Desktop.
Save nburkley/d0f7d1b5b12fc9832404e7e28b42d02e to your computer and use it in GitHub Desktop.
Use `bbc` instead of `to` to hide list of recipienta
users_by_locale.each do |locale, locale_users|
I18n.with_locale(locale) do
mail(
bcc: locale_users.map(&:email),
subject: I18n.t('user_mailer.new_follower.subject')
)
end
end
private
def users_by_locale
@users.group_by { |user| user.locale }
end
@glaszig
Copy link

glaszig commented Dec 30, 2019

careful! this will leak all your users email addresses to all of them since most mail servers will just send the :to addresses as part of every mail. you should be using a combination of one to address and many other :bcc address. or send them all separately in a background process.

@nburkley
Copy link
Author

@glaszig, good point — I've updated the gist to use bbc instead of to. Thanks for bringing it to my attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment