title: Action Mailer in Ruby without Rails - Timeout Error
body: <p>I'm using Action Mailer to send a daily email, but without Rails. I've also looked at other questions here: <a href="https://stackoverflow.com/questions/4951310/actionmailer-3-without-rails">Action Mailer 3 without Rails</a>, <a href="https://stackoverflow.com/questions/741989/actionmailer-and-ramaze">ActionMailer and Ramaze</a></p>
  
  <p>Here's my code:</p>
  
  <pre><code>require 'action_mailer'
  
  class Mailer &lt; ActionMailer::Base
    def daily_names_email(names,subject="test daily mail",to = "test@domain.com")
    @names = "test names"
    mail(
        :to      =&gt; to,
        :from    =&gt; "me@domain.com",
        :subject =&gt; subject
      ) do |format|
      format.text
      format.html
      end
    end
  end
  
  Mailer.raise_delivery_errors = true
  Mailer.delivery_method = :smtp
  Mailer.smtp_settings = {
   :address   =&gt; "smtp.gmail.com",
   :port      =&gt; 465,
   :domain    =&gt; "google",
   :authentication =&gt; :plain,
   :user_name      =&gt; "me@domain.com",
   :password       =&gt; "*****",
   :enable_starttls_auto =&gt; true
  }
  Mailer.view_paths = File.dirname(__FILE__)
  Mailer.logger = Logger.new(STDOUT)
  
  email = Mailer.daily_names_email('hello')
  
  puts email
  email.deliver
  </code></pre>
  
  <p>Here's the Error output:</p>
  
  <pre><code>Date: Thu, 19 Jul 2012 08:46:18 +0800
  From: me@domain.com
  To: me@domain.com
  
  Message-ID: &lt;500758da4dbda_151082d87c10766@ubuntu.mail&gt;
  Subject: test daily mail
  Mime-Version: 1.0
  Content-Type: multipart/alternative;
   boundary="--==_mimepart_500758da4a289_151082d87c104fb";
   charset=UTF-8
  Content-Transfer-Encoding: 7bit
  ----==_mimepart_500758da4a289_151082d87c104fb
  Date: Thu, 19 Jul 2012 08:46:18 +0800
  Mime-Version: 1.0
  Content-Type: text/plain;
   charset=UTF-8
  Content-Transfer-Encoding: 7bit
  Content-ID: &lt;500758da4c2f6_151082d87c10515@ubuntu.mail&gt;
  
  /usr/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error)
  from /usr/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
  from /usr/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
  from /usr/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
  from /usr/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
  from /usr/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start'
  from /usr/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
  from /usr/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start'
  from /usr/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
  from /var/lib/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
  from /var/lib/gems/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
  from /var/lib/gems/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
  from /var/lib/gems/1.9.1/gems/actionmailer-3.2.6/lib/action_mailer/base.rb:415:in `block in deliver_mail'
  from /var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `block in instrument'
  from /var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  from /var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `instrument'
  from /var/lib/gems/1.9.1/gems/actionmailer-3.2.6/lib/action_mailer/base.rb:413:in `deliver_mail'
  from /var/lib/gems/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
  from mailer.rb:34:in `&lt;main&gt;''
  </code></pre>
  
  <p>Any help would be appreciated! Thanks in advance!</p>