Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Last active December 23, 2015 09:49
Show Gist options
  • Save bjhaid/6617090 to your computer and use it in GitHub Desktop.
Save bjhaid/6617090 to your computer and use it in GitHub Desktop.
def send_message(subject,message,sender,to,password)
msg = <<END_OF_MESSAGE
From: #{sender}
To: #{to}
MIME-Version: 1.0
Content-type: text/html
Subject:#{self.load_config['opco']} #{subject}
#{message}
END_OF_MESSAGE
begin
smtp = Net::SMTP.new('smtp.gmail.com', 465)
smtp.enable_tls
smtp.set_debug_output $stderr
smtp.start('127.0.0.1',sender,password,'plain') do |smtp|
smtp.send_message(msg,sender,to.split(","))
end
rescue => e
puts e.backtrace
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment