简体   繁体   中英

Gem mailcatcher - do not received emails

I create new user. After creating should received confirmation mail. but when i open mailcatcher( http://127.0.0.1:1080/ )... nothing!

i use mailcatcher v. 0.5.12, Rails 3.2.22

In development.rb added:

# Don't care if the mailer can't send
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
  config.action_mailer.raise_delivery_errors = true 

What is wrong with settings? How check error? Please, help, thank you.

UPDATE

Confirmationcontroller:

class ConfirmationsController < Devise::ConfirmationsController

  def new
    super
    resource.login = current_user.email if user_signed_in?
  end

  protected

  def after_resending_confirmation_instructions_path_for(resource_name)
    if user_signed_in?
      home_path
    else
      new_session_path(resource_name)
    end if is_navigational_format?
  end

  # The path used after confirmation.
  def after_confirmation_path_for(resource_name, resource)
    '/profile'
  end
end

userscontrollers.rb:

# encoding: utf-8
class UsersController < ApplicationController
  before_filter :require_admin, only: [:add_moderator, :remove_moderator, :destroy]
  before_filter :require_moderator, only: [:edit, :update, :paid_on, :paid_off,
                                           :ban, :unban]
  before_filter :authenticate_user!, except: [:new, :create]
  before_filter :load_user, only: [:show, :photos, :videos, :audios,
                                   :buy_rating, :do_buy_rating,
                                   :add_moderator, :remove_moderator,
                                   :edit, :update, :paid_on, :paid_off, :ban, :unban, :destroy,
                                   :add_funds, :mute, :unmute]

  layout :determine_layout

  def new
    @user = User.new
    @invite = Invite.find_by_code(session[:invite]) if session[:invite].present?
    @user.email = @invite.email if @invite
  end

  def create
    @user = User.new(params[:user])
    raise ActiveRecord::RecordInvalid.new(@user) unless verify_recaptcha(model: @user, message: 'message')
    @invite = Invite.find_by_code(session[:invite]) if session[:invite].present?
    User.transaction do
      @user.save!
      @user.current_password = @user.password
      @user.theme_ids = params[:user][:theme_ids]
      @user.group_ids = [114, 130] 
      @user.save!
    end
    if @invite
      @invite.new_user = @user
      @invite.use!
    end
    redirect_to @user
  rescue ActiveRecord::RecordInvalid
    render :new
  end

  .........................................................
  .........................................................

private

  def determine_layout
    return 'welcome' if %w(new create).include?(params[:action])
    return 'dating' if params[:action]=='search'
    'inner'
  end
end

registrationscontroller.rb:

# encoding: utf-8
class RegistrationsController < Devise::RegistrationsController
  def create
    if verify_recaptcha
      super
    else
      flash.delete :recaptcha_error
      build_resource
      resource.valid?
      resource.errors.add(:base, :invalid_recaptcha)
      # clean_up_passwords(resource)
      render :new
    end
  rescue ActiveRecord::RecordNotUnique
    render :new
  end

  def update
    redirect_to '/settings'
  end
  # def update
  #   # required for settings form to submit when password is left blank
  #   if params[:user][:password].blank?
  #     params[:user].delete("password")
  #     params[:user].delete("current_password")
  #   end
  # 
  #   @user = User.find(current_user.id)
  #   if update_user
  #     set_flash_message :notice, :updated
  #     # Sign in the user bypassing validation in case his password changed
  #     sign_in @user, :bypass => true
  #     redirect_to after_update_path_for(@user)
  #   else
  #     render "edit"
  #   end
  # end

  def edit
    redirect_to '/settings'
  end

  def destroy
    current_password = params[:user].delete(:current_password)
    if resource.valid_password?(current_password)
      resource.mark_as_deleted!
      render inline: "$('body').fadeOut(3000, function() { document.location = 'http://ya.ru'; })"
    else
      render inline: "$.flash.error('error')"
    end
    # Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
    # set_flash_message :notice, :destroyed if is_navigational_format?
    # respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
  end

  protected

  def after_sign_up_path_for(resource)
    '/profile'
  end

end

Code was without Devise.mail_confirmation_instructions(@user).deliver. I realized, now all in fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM