One of my favorite ways to send mail from Ruby is through the Pony gem. If you haven’t used it, it’s definitely worth a look. I recently found the need to send mail to multiple recipients, and I couldn’t figure out how based on their documentation.
With a little experimentation, I found that you can simply separate the recipients with a comma, like so:
This works for the To
field, as well as the CC
and BCC
fields. You can simplify this, especially when the recipients are obtained at run time, by using an array of recipients with the join
method.
Update:
As Jeff points out below, you can actually use an array directly! That makes the above simpler:
This will certainly be my go-to method from now on. Thanks Jeff!