Sending an email from the mail gem

To send an email using the 'mail' gem I had to set :enable_starttls_auto to false.

require 'mail'

Mail.defaults do
  delivery_method :smtp, { :address              => "localhost",
                          :port                 => 25,
                          :domain               => 'j--r.info',
                          :user_name            => nil,
                          :password             => nil,
                          :authentication       => nil,
                          :enable_starttls_auto => false  }

  retriever_method :pop3, { :address             => "localhost",
                           :port                => 995,
                           :user_name           => nil,
                           :password            => nil,
                           :enable_ssl          => true }
end
 
Mail.deliver do
  from    'jrobertson@j--r.info'
  to      'james@r0bertson.co.uk'
  subject 'test 222'
  body    'testing all the way'   
end

here's another way this t ime using a hash:

Mail.new(
   from:    'jrobertson@j--r.info',
   to:      'james@r0bertson.co.uk',
   subject: 'test 333',
   body:    'testing all the way'   
).deliver!


Resources

Tags:
Source:
2048hrs.txt
Published:
10-08-2012 20:48