Simple integration of gmail’s emailing service using Net::Smtp package. Before using it, just make sure to change the from and to addresses, and insert your gmail authentication data.
require "net/smtp" require "time" # for rfc2822 # sender from_addr = "insert_from_address_here" # receiver to_addr = "insert_receiver_address_here" mail_content = <<END_OF_CONTENT From: #{from_addr} To: #{to_addr} Subject: Just a test Date: #{Time.now.rfc2822} Just a test of sending email via Ruby. END_OF_CONTENT smtp = Net::SMTP.new("smtp.gmail.com",587) smtp.enable_starttls smtp.start("smtp.gmail.com","your_gmail_username","your_gmail_password",:login) do smtp.send_message(mail_content, from_addr, to_addr) end |
Code is available for download here:code