I have the following setup to send email at sign up:
Rails 3.0.7
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
rails plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
Mailer
class UserMailer < ActionMailer::Base
def registration_confirmation(user)
recipients user.email
from "webmaster@example.com"
subject "Thank you for Registering"
body :user => user
end
end
Controller:
def create
@user = User.new(params[:user])
if @user.save
UserMailer.deliver_registration_confirmation(@user)
sign_in @user
flash[:success] = "Welcome to ECE"
redirect_to @user
else
@title = "Sign up"
render 'new'
end
end
View:
Hi <%= @user.name %>, .....
I was getting smtp connection errors and I included this in gemfile after googling.
This is solved the error
Gemfile
gem 'rack-ssl', :require => 'rack/ssl'
Config/environment/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:authentication => :login,
:port => 587,
:domain => 'www.example.com',
:name => 'user@gmail.com',
:password => 'password',
}
Problem
earler I was getting 535-5.7.1 Username and Password not accepted.
Now it says:
SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don’t have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
Any suggestion?
I’ve been using gmail for sending emails, and have never configured any extra gems. This is what I’ve in development.rb.
The points to be noted are:
Note: The value for :domain is google apps domain. I think its not required if you are using the username which belongs to gmail.com.