Skip to content

Instantly share code, notes, and snippets.

@coderhs
Created October 9, 2013 13:37
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 coderhs/9341b8684c56dccd3513 to your computer and use it in GitHub Desktop.
Save coderhs/9341b8684c56dccd3513 to your computer and use it in GitHub Desktop.
require 'net/smtp'
def sendEmail(to, subject, message)
to=to.to_s()
to.gsub!(" ","")
to.gsub!(";",",")
smtp = Net::SMTP.new('smtp.gmail.com', 587)
smtp.enable_starttls
smtp.start("smtp.gmail.com","myemail@gmail.com","password",:login)
to.split(",").each {|email|
emailMessage = "From: myemail <myemail@gmail.com>
To: <#{email.to_s()}>
Subject: #{subject.to_s()}
Content-Type: text/html;
#{message.to_s()}
"
smtp.send_message(emailMessage.to_s(),"myemail@gmail.com", email.to_s())
}
end
t = Thread.new do
sendEmail("myemail@gmail.com","mysubject","mybody")
end
while(t.alive?)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment