Check out http://wanlord.com/articles/2007/11/29/sending-email-using-actionmailer-and-gmail
First, I'm sorry if I'm repeating much, but I'll give you everything
I've got. I'm not sure what's happening on your end, but here's what
I have. The following is in lib/smtp_tls.rb:
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
check_response(critical { recv_response() })
do_helo(helodomain)
if starttls
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
do_helo(helodomain)
end
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') rescue return false
return true
end
def quit
begin
getok('QUIT')
rescue EOFError
end
end
end
Toward the top of my config/environment.rb file, I have:
require 'smtp_tls'
In the Rails::Initializer.run do |config| block, I have:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_charset = 'utf-8'
At the bottom of that same file, I have:
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => 'email@mydomain.com',
:password => 'pass'
}
I think that's everything in my app dealing with email settings. Have
you been able to get it working with sendmail first? Maybe there's
something elsewhere in your app? I haven't used mailer.yml - perhaps
the "old-fashioned" way would work for you?
-Kyle