Last active
August 29, 2015 13:56
-
-
Save papanikge/9226218 to your computer and use it in GitHub Desktop.
Bulk send of e-mails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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