I am trying implementing send mail through action mailer in rails related code are..
my mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "bkdebasish90@gamil.com"
def registration_confirmation(user)
mail(:to=>user.email, :subject =>"Registered")
end
end
users.controller is
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
UserMailer.registration_confirmation(@user).deliver
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
Here, Your initializer\setup_mail.rb setting will go to the development.rb
config.action_mailer.default_url_options = { host: 'localhost', port: 9292 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address =>"smtp.thejaingroup.com",
:domain =>"thejaingroup.com",
:port => 587,
:user_name =>"debasish@thejaingroup.com",
:password =>"************"
:authentication =>"plain"
}
and my view is .. user_registration.text.erb ---is
Hi sir you successfully Completed signed..........!
my have a error msg after running this apps.. SocketError in UsersController#create getaddrinfo: The requested name is valid, but no data of the requested type was found.
Aucun commentaire:
Enregistrer un commentaire