SMTP with Gmail in 1.9.2

Hi guys,

I’ve got a program that has been working fine running 1.8.6 using the
smtp_tls gem to send emails via my gmail account. I’v now removed the
smtp_tls gem because I was under the impression it was included in Ruby
core now.

I’ve upgraded to 1.9.2 and the code I wrote is now failing:

require ‘net/smtp’

def send_email_via_smtp(message, destination_email)
Net::SMTP.start(‘’, 587, ‘localhost.localdomain’,
USERNAME, PASSWORD, ‘plain’) do |smtp|
smtp.send_message(message, EMAIL_ADDR_THAT_SENDS_EM,

When I run the app the first line of the above method is causing this
exception to be thrown:

C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:954:in check_auth_response': 530 5.7.0 Mu st issue a STARTTLS command first. r36sm4454744qcs.39 (Net::SMTPAuthenticationEr ror) from C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:731:in auth_plain’
from C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:723:in authenticate' from C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:566:in do_start’
from C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:525:in start' from C:/Ruby192/lib/ruby/1.9.1/net/smtp.rb:463:in start’
from C:/Program Files/EmailOMatic/src/emailer.rb:36:in

Any thoughts to why this change is breaking my code?

Thanks for your assistance,

I’ve been digging around in the source code.

I found I need to call smtp.enable_starttls to get the starttls enabled.

Here’s my now working code from above:

def send_email_via_smtp(message, destination_email)
smtp =‘’, 587)
smtp.start(‘localhost.localdomain’, USERNAME, PASSWORD, ‘plain’) do
connection.send_message(message, EMAIL_ADDR_THAT_SENDS_EM,