Mail merge ruby script
The other day, I needed to send the gmail invite to all the folks in the development team and it amounted to more than 30 people. Since each one would have to be sent a different invite, distribution list won't work. Here is a quick Ruby script I cranked up to send the invites. Go ruby.
require 'net/smtp'
receiver_list = ['x@y.com','a@b.com']
invites_list = ['invite_url_1','invite_url_2']
smtp = Net::SMTP.start('mta1.mycompany.com', 25)
sender = 'me@gmail.com'
receiver_list.each_index {|email_index|
receiver = receiver_list[email_index]
invite_link = invites_list[email_index]
puts "Sending e-mail to " + receiver
msgstr = "From: Venkat <#{sender}>\n"
msgstr += "To: #{receiver} <#{receiver}>\n"
msgstr += "Subject: Gmail invitation\n"
msgstr += "I would like you to enjoy a small gift, a new Gmail account.\n"
msgstr += "#{invite_link}\n\n"
msgstr += "Cheers,\n"
msgstr += "Venkat.\n"
puts smtp.send_mail(msgstr, sender, receiver)
}