Using NeverBounce Ruby API to Check Email Deliverability
It is important to maintain a good email reputation. You can see your email reputation in the dashboard.
I am using the gem neverbounce-api verion 1.0.4. Here is the code to validate with retries.
class EmailAddress MAX_RETRIES = 3 def self.deliverable?(email) times_retried = 0 begin client = NeverBounce::API::Client.new(api_key: Credential.never_bounce_secret_api_key) response = client.single_check(email: email) result = if response.ok? response.result == "valid" else false end result rescue Net::ReadTimeout => error if times_retried < MAX_RETRIES times_retried += 1 retry else false end end end end
One of the exception that can occur is due to not having enough credits to make the API calls. I am not handling this exception in the code because you can configure NeverBounce to email you when the balance is low.
Ace the Technical Interview
- Easily find the gaps in your knowledge
- Get customized lessons based on where you are
- Take consistent action everyday
- Builtin accountability to keep you on track
- You will solve bigger problems over time
- Get the job of your dreams
Take the 30 Day Coding Skills Challenge
Gain confidence to attend the interview