Created
January 20, 2011 02:14
-
-
Save postnati/787290 to your computer and use it in GitHub Desktop.
Send email from Ruby using google's smtp server
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
require 'net/smtp' | |
def send_email(from, from_alias, to, to_alias, subject, message) | |
msg = <<END_OF_MESSAGE | |
From: #{from_alias} <#{from}> | |
To: #{to_alias} <#{to}> | |
Subject: #{subject} | |
#{message} | |
END_OF_MESSAGE | |
smtp = Net::SMTP.new 'smtp.gmail.com', 587 | |
smtp.enable_starttls | |
# smtp.start(YourDomain, YourAccountName, YourPassword, :login) | |
smtp.start("pattison@atomicobject.com", "pattison@atomicobject.com", "abc123", :login) do |smtp| | |
smtp.send_message msg, from, to | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment