Sending emails using Ruby with nothing more than the core library and a csv
Tonight I wanted to accomplish something easy. Read a list of email addresses from a CSV file and send a generic message to those email addresses.
Here is the code I came up with in about 5 minutes or so.
Look at this:
There you go CSV read, and I have an array of the email addresses.
The rest of the code I have already spoken about in this [post][email]. One thing that I am curious about is the message variable. There must be a more efficient way to do that? Though the performance hit right now is tiny I don’t want to get into the habit of writing inefficient / slow code. I only spent around 5 minutes on this and clearly it can be done and should be done better. Therefore, my mission for the rest this week is to find a way to make that bit of code more concise and make the whole loop more efficient.
Did I say I love Ruby?!?!?
Right now is also a good time to dive into the many different gems that give you the ability to send an email. I am going to discuss that some more in the coming days and try and figure out in which different scenarios you might prefer one gem over another.