Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hmm reading the network/delivery_methods/smtp.rb, it doesn't look like it support Direct SSL. TLS isn't them same, as the connection starts out Plain Text and then Switches to SSL on the starttls command. Can you just use starttls on port 587?</p> <p>pulling my comment up.</p> <p>see</p> <p><a href="https://stackoverflow.com/questions/708858/how-to-send-mail-with-ruby-over-smtp-with-ssl-not-with-rails-no-tls-for-gmail">How to send mail with ruby over smtp with ssl (not with rails, no TLS for gmail)</a></p> <p>Which suggests that you can monkey patch Net::SMTP to do it..</p> <p>Ok kinda found the issue and can patch around it, but so far this solution is yucky.. but it does work :) </p> <pre><code>#!/usr/bin/env ruby require 'rubygems' require "openssl" require "net/smtp" require "mail" Net::SMTP.class_eval do def self.start( address, port = nil, helo = 'localhost.localdomain', user = nil, secret = nil, authtype = nil, use_tls = false, use_ssl = true, &amp;block) # :yield: smtp new(address, port).start(helo, user, secret, authtype, use_tls, use_ssl, &amp;block) end def start( helo = 'localhost.localdomain', user = nil, secret = nil, authtype = nil, use_tls = false, use_ssl = true ) # :yield: smtp start_method = use_tls ? :do_tls_start : use_ssl ? :do_ssl_start : :do_start if block_given? begin send start_method, helo, user, secret, authtype return yield(self) ensure do_finish end else send start_method, helo, user, secret, authtype return self end end private def do_tls_start(helodomain, user, secret, authtype) raise IOError, 'SMTP session already started' if @started check_auth_args user, secret sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) } @socket = Net::InternetMessageIO.new(sock) @socket.read_timeout = 60 #@read_timeout @socket.debug_output = STDERR #@debug_output check_response(critical { recv_response() }) do_helo(helodomain) raise 'openssl library not installed' unless defined?(OpenSSL) starttls ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true ssl.connect @socket = Net::InternetMessageIO.new(ssl) @socket.read_timeout = 60 #@read_timeout @socket.debug_output = STDERR #@debug_output do_helo(helodomain) authenticate user, secret, authtype if user @started = true ensure unless @started # authentication failed, cancel connection. @socket.close if not @started and @socket and not @socket.closed? @socket = nil end end def do_ssl_start(helodomain, user, secret, authtype) raise IOError, 'SMTP session already started' if @started check_auth_args user, secret sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) } raise 'openssl library not installed' unless defined?(OpenSSL) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true ssl.connect @socket = Net::InternetMessageIO.new(ssl) @socket.read_timeout = 60 #@read_timeout @socket.debug_output = STDERR #@debug_output check_response(critical { recv_response() }) do_helo(helodomain) do_helo(helodomain) authenticate user, secret, authtype if user @started = true ensure unless @started # authentication failed, cancel connection. @socket.close if not @started and @socket and not @socket.closed? @socket = nil end end def do_helo(helodomain) begin if @esmtp ehlo helodomain else helo helodomain end rescue Net::ProtocolError if @esmtp @esmtp = false @error_occured = false retry end raise end end def starttls getok('STARTTLS') end def quit begin getok('QUIT') rescue EOFError, OpenSSL::SSL::SSLError end end end options = { :address =&gt; "mail.domain.net", :port =&gt; 466, :domain =&gt; 'mail.domain.net', :user_name =&gt; 'doon@domain.net', :password =&gt; 'Secret!', :authentication =&gt; 'login', :use_ssl =&gt; true } Mail.defaults do delivery_method :smtp, options end mail = Mail.new do from 'doon@domain.net' to 'doon@someotherdomain.com' subject 'This is a test email' body File.read('body.txt') end puts mail.to_s mail.deliver! </code></pre> <p>for some reason the use_ssl in the orig monkey patch doesn't make it in, and couple that with VERSION being undefined in Net::SMTP. So I changed that out, and forced use_ssl to be true, and was able to send email..</p>
 

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