Does anyone have any quality (and up-to-date) information regarding sending mail via Gmail using Ruby’s Net::SMTP? I’ve seen several examples — most dating from 2007 to mid-2008 and none of them work for me. I need more current examples that use the most recent 1.8.7 release. I’d also appreciate if the documentation didn’t only cover simple examples that no one ever really uses.
Currently I’m receiving an error:
SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol
I’m not terribly familiar with SSL as regards the SMTP protocol, so this is all lost on me. Unfortunately the Net::SMTP documentation only covers the bases and doesn’t provide a full list of the various potential OpenSSL::SSL contexts either so I can’t try various ones.
Anyway, if anyone has any quality info on getting this to work with Gmail it would be most appreciated.
Best.
I actually just got this working. Wrote a quick script to test it.
I was getting a different error than you were (requiring STARTTLS), I also found I had to use port 587 instead of 465.
I found the trick to get it working in a Rails plugin I found. (agilewebdevelopment.com/plugins/net_smtp_tls_support)
if you ‘eval’ this file (it adds tls support to the standard Net::SMTP library):
then run ‘Net::SMTP.enable_tls()’
everything seems to work fine.
Here’s my code:
obviously, i downloaded the above mentioned file to the same directory and named it ‘smtp_tls.rb’
Hope this helps!