Ask A Question

Notifications

You’re not receiving notifications from this thread.

Tutorial on verifalia gem

Thomas Connolly asked in Rails

Having trouble setting this up on my Rails 7 app. A tutorial would be very helpful! Some goofball is using a bot to clog up my db with fake users. I've got him throttled to one a day, but it's quite annoying and potentially harmful if my app keeps sending emails to nonexistent email addresses (I could be labeled a scammer).
The instructions are probably quite good but they're all Ruby, not RoR, and I haven't learned enough POR, unfortunately. A Rails 7 approach would be much appreciated. Thanks.

Reply

Hi there,

I'm sorry to hear you're having trouble setting up email verification on your Rails 7 app. I understand how frustrating it can be dealing with fake users and the potential risks of sending emails to nonexistent addresses. A Rails-specific tutorial can definitely make things easier.

To help you out, here's a step-by-step guide to integrate MailTester Ninja with your Rails 7 application:

  1. Add the MailTester Ninja gem to your Gemfile:

    gem 'mailtester_ninja'
    
  2. Run bundle install:

    bundle install
    
  3. Create an initializer: In config/initializers, create a file named mailtester_ninja.rb and add your API key:

    MailTesterNinja.configure do |config|
      config.api_key = 'your_api_key_here'
    end
    
  4. Verify emails before saving users: In your User model (app/models/user.rb), add a before_save callback to verify email addresses:

    class User < ApplicationRecord
      before_save :verify_email
    
      private
    
      def verify_email
        response = MailTesterNinja.verify(email)
        unless response.valid?
          errors.add(:email, "is invalid")
          throw(:abort)
        end
      end
    end
    
  5. Handle verification results: Customize the error handling and user feedback as needed. You might want to display a message to the user if their email address is invalid.

  6. Testing: Test the setup by attempting to create a user with an invalid email address and ensuring it gets rejected.

This should help you integrate email verification into your Rails 7 app and prevent fake users from clogging your database. If you have any further questions or run into issues, feel free to ask!

Best regards,


Let me know if you need any more assistance!

Reply

Cloudflare as a proxy could help block the malicious user. They can block requests from known bots and present barriers to stop them.

They also run hCaptcha that you can implement in the sign up process to protect from bots. We have a lesson on that here: https://gorails.com/episodes/how-to-usehcaptcha-with-ruby-on-rails

I also like using invisible_captcha which is similar and doesn't require a third-party service (although it's not quite as good).

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.