Tutormetro uses Google Apps For Your Domain, and all email flows throw Google’s servers. Unfortunately, Rails 1.2.2 or later cannot send via smtp.google.com out of the box as it use tls, which standard ruby package is not included.
There is a solution from http://railsforum.com/viewtopic.php?id=12875 .We have deployed and tested in our Pilot site. Here are the step we go thro.
#vendor/plugins/action_mailer_tls/init.rb
require_dependency ’smtp_tls’#vendor/plugins/action_mailer_tls/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 secretsock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
@socket.debug_output = STDERR #@debug_outputcheck_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
enddef 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
enddef starttls
getok(’STARTTLS’)
enddef quit
begin
getok(’QUIT’)
rescue EOFError
end
end
end# config/initializers/mail.rbActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => “smtp.gmail.com”,
:port => 587,
:authentication => :plain,
:user_name => “username@your-domain.com”,
:password => “password”}
Configuring Rails 2.1 To Use Gmail’s SMTP Server | Available Domains - Industry leading domain name news
June 30th, 2008 at 8:02 pm
[...] original here: Configuring Rails 2.1 To Use Gmail’s SMTP Server archives, categories, copyright, design-disease, development, high-value-domain-name, [...]