Note that there are some explanatory texts on larger screens.

plurals
  1. POSend email from Ruby program with TLS
    primarykey
    data
    text
    <p>I am trying to send an email from a Ruby program. The smtp server is an Exchange 2007 server that requires me to login to send the email.</p> <pre><code>#!/usr/bin/ruby require 'rubygems' require 'net/smtp' msgstr = "Test email." smtp = Net::SMTP.start('smtp.server.com', 587, 'mail.server.com', 'username', 'password', :login) do |smtp| smtp.send_message msgstr, 'from@server.com', 'to@server.com' end </code></pre> <p>When I run this I get the following error.</p> <pre><code>/usr/lib/ruby/1.8/net/smtp.rb:948:in `check_auth_continue': 530 5.7.0 Must issue a STARTTLS command first (Net::SMTPAuthenticationError) from /usr/lib/ruby/1.8/net/smtp.rb:740:in `auth_login' from /usr/lib/ruby/1.8/net/smtp.rb:921:in `critical' from /usr/lib/ruby/1.8/net/smtp.rb:739:in `auth_login' from /usr/lib/ruby/1.8/net/smtp.rb:725:in `send' from /usr/lib/ruby/1.8/net/smtp.rb:725:in `authenticate' from /usr/lib/ruby/1.8/net/smtp.rb:566:in `do_start' from /usr/lib/ruby/1.8/net/smtp.rb:525:in `start' from /usr/lib/ruby/1.8/net/smtp.rb:463:in `start' </code></pre> <p>I can't find anything in the <a href="http://www.ruby-doc.org/core/classes/Net/SMTP.html" rel="noreferrer">Ruby api for Net::SMTP</a> referencing TLS or a STARTTLS command.</p> <p><strong>EDIT: Download smtp-tls.rb, the code doesn't change much but here is what I got to work.</strong></p> <pre><code>#!/usr/bin/ruby require 'rubygems' require 'net/smtp' require 'smtp-tls' msgstr = &lt;&lt;MESSAGE_END From: me &lt;me@test.com&gt; To: you &lt;you@test.com&gt; Subject: e-mail test body of email MESSAGE_END smtp = Net::SMTP.start('smtp.test.com', 587, 'test.com', 'username', 'passwd', :login) do |smtp| smtp.send_message msgstr, 'me@test.com', ['you@test.com'] end </code></pre> <p><strong>EDIT: Works with ruby 1.8.6</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload