Skip to content

Instantly share code, notes, and snippets.

@mfkp
Created November 12, 2014 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfkp/15b8716c37702c088201 to your computer and use it in GitHub Desktop.
Save mfkp/15b8716c37702c088201 to your computer and use it in GitHub Desktop.
mail spammer for testing lots of emails
require 'net/smtp'
# instructions:
# set 2 environment variables: EMAIL & PW (assuming gmail in smtp settings)
# change from_domain to your email provider domain
# change from_name to your name
# change 'to' to the recipients of your spam
# run 'ruby spam.rb'
def sendMail(body)
from = ENV['EMAIL']
from_domain = 'gmail.com'
from_name = 'Kyle Powers'
to = %w(email@sample.com email2@sample.com)
subject = "KYLE IS JUST.BEST #{rand(1..50)}"
message = <<MESSAGE
From: #{from_name} <#{from}>
To: #{to.join(', ')}
MIME-Version: 1.0
Content-type: text/html
Subject: #{subject}
MESSAGE
smtp = Net::SMTP.new('smtp.gmail.com', 587)
smtp.enable_starttls
smtp.start(from_domain, from, ENV['PW'], :login) do
smtp.send_message([message, body].join("\r\n"), from, to)
end
end
loop do
sendMail(Time.now.to_i.to_s(36))
puts 'Email sent at ' + Time.now.to_s
pauseTime = rand(1..3)*60 # sleep between 1 and 3 minutes
puts 'Sleeping for ' + (pauseTime/60).to_s + ' minutes'
sleep pauseTime
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment