Sending confirmation emails to registered users in ROR app via localhost

前端 未结 3 666
时光取名叫无心
时光取名叫无心 2020-12-20 07:21

In my ROR app, I am trying to send confirmation emails to my registered users when they signup, my website is on localhost currently. I am getting this error:



        
3条回答
  •  旧时难觅i
    2020-12-20 08:13

    ** development.rb**

    config.action_mailer.delivery_method = :sendmail
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    

    ** Users_controller.rb **

    def new
      UserMailer.registration_confirmation(@user).deliver
    end
    def create
      @user = User.new(params[:user])
      if @user.save
        UserMailer.registration_confirmation(@user).deliver
        sign_in @user
        flash[:success] = "Welcome!"
        redirect_to @user
      else
        render 'new'
      end
    end
    

    ** User_mailer.rb **

     def registration_confirmation(user) 
       @message = 'whatever you want to say here!'
       mail(:from => "myemailid@gmail.com", :to => user.email, :subject => "Thank you for registration")
    end
    

    **/app/views/user_mailer/registration_confirmation.text.erb *

    <%= @message %>
    

    That's what I've done in my development mode, and it works

提交回复
热议问题