Gmail use TLS that isn't supported by Ruby 1.8.
You can use tlsmail.
# gem install tlsmail
A sample code.
require 'tlsmail'
require 'time'
content = <<EOF
From: from@gmail.com
To: to@gmail.com
Subject: Hello!
Date: #{Time.now.rfc2822}
How are you.
EOF
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', 'from@gmail.com', 'password', :login) do |smtp|
smtp.send_message(content, 'from@gmail.com', 'to@gmail.com')
end
This code don't work in Ruby 1.8.3.
10 comments:
This post helped me to successfully use Ruby to send email through Gmail.
Domo arigato gozaimasu!
I've gone through so many sites that had help for sending email via gmail smtp, but yours was the only one that actually helped! Thanks very much!
Awesome! The only thing to add as usual is
require 'rubygems'
You saved me time. Thanks
Ram
yeap !.
Very thanks dude..
It helped me a lot..
Great job..
Thanks buddy
I'm very grateful for this easy code but ... is there a straightforward way of adding an attachment?
Thx,
Colin
Thank you very much ;-)
You're the best :P
I needed to send email from a ruby script, but outside of the rails environment
Worked great, Thanks!
this is so awesome.
thank you.
Thank you so much, tried so many different solutions and here your's worked perfectly. Gd Bless you.
This is really useful, THANK YOU.
Post a Comment