Skip to content

Instantly share code, notes, and snippets.

@papanikge
Last active August 29, 2015 13:56
Show Gist options
  • Save papanikge/9226218 to your computer and use it in GitHub Desktop.
Save papanikge/9226218 to your computer and use it in GitHub Desktop.
Bulk send of e-mails
#!/usr/bin/env ruby
# Send batch mail without the recipients able to identify each other
# You're supposed to give the recipients as command line arguments
# 'papanikge' 2013
require 'mail'
abort if ARGV.empty?
# My e-mail and password
ME = ''
PASS = ''
# What to send
SUBJ = ''
BODY = %{}
# Initial settings. Maybe get them from arguments..
options = { :address => "smtp.gmail.com",
:port => 587,
:authentication => 'plain',
:user_name => ME,
:password => PASS,
:enable_starttls_auto => true
}
Mail.defaults { delivery_method :smtp, options }
# Sending
ARGV.each do |arg|
Mail.deliver do
to arg
from ME
subject SUBJ
body BODY
end
puts "Mail sent to #{arg}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment