truemail-rb / truemail

🚀 Configurable framework agnostic plain Ruby 📨 email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.
https://truemail-rb.org/truemail-gem
MIT License
1.19k stars 60 forks source link

[QUESTION] IP Blocked for STMP Validation #101

Closed mhtngo closed 4 years ago

mhtngo commented 4 years ago

New Issue Checklist

Issue Description

General question - hosting this AWS/EC2 - some domains block my IP for SMTP validation type. For example Outlook.com

What is general best practice to host truemail to prevent these blocked IP SMTP verification issues?

Complete output when running truemail, including the stack trace and command used
[INSERT OUTPUT HERE]
bestwebua commented 4 years ago

Hi, @mhtngo Thx for your question. Please check your verifier host preconditions first. Also I think that more flexible solution is to use Truemail outside of your application. For this case you can move out your Truemail instance to another cloud provider or even bare metal with white ip address. Anyway, ask the questions and I'll try to help you.

Example of Truemail verification of some email hosted on outlook.com:

Truemail gem (2.0.1), hosted on DO, successful case:

Truemail.validate('admin@outlook.com')

=> #<Truemail::Validator:0x00007fac98538c60
 @result=
  #<struct Truemail::Validator::Result
   success=true,
   email="admin@outlook.com",
   domain="outlook.com",
   mail_servers=["104.47.57.161", "104.47.58.161"],
   errors={},
   smtp_debug=nil,
   configuration=
    #<Truemail::Configuration:0x00007fac98538d00
     @blacklisted_domains=[],
     @connection_attempts=2,
     @connection_timeout=2,
     @default_validation_type=:smtp,
     @email_pattern=
      /(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-|.|+]*)@((?i-mx:[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}))\z)/,
     @not_rfc_mx_lookup_flow=false,
     @response_timeout=2,
     @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
     @smtp_safe_check=false,
     @validation_type_by_domain={},
     @verifier_domain="my.domain",
     @verifier_email="admin@my.domain",
     @whitelist_validation=false,
     @whitelisted_domains=[]>>,
 @validation_type=:smtp>

Truemail server, hosted on AWS, successful case:

{
  "configuration": {
    "blacklisted_domains": null,
    "email_pattern": "default gem value",
    "not_rfc_mx_lookup_flow": false,
    "smtp_error_body_pattern": "default gem value",
    "smtp_safe_check": false,
    "validation_type_by_domain": null,
    "whitelist_validation": false,
    "whitelisted_domains": null
  },
  "date": "2020-10-22 07:49:45 +0000",
  "email": "admin@outlook.com",
  "errors": null,
  "smtp_debug": null,
  "success": true,
  "validation_type": "smtp"
}

Truemail server, hosted on AWS, failure case:

{
  "configuration": {
    "blacklisted_domains": null,
    "email_pattern": "default gem value",
    "not_rfc_mx_lookup_flow": false,
    "smtp_error_body_pattern": "default gem value",
    "smtp_safe_check": false,
    "validation_type_by_domain": null,
    "whitelist_validation": false,
    "whitelisted_domains": null
  },
  "date": "2020-10-22 08:12:16 +0000",
  "email": "ololo42mnbvcxz@outlook.com",
  "errors": {
    "smtp": "smtp error"
  },
  "smtp_debug": [
    {
      "connection": true,
      "errors": {
        "rcptto": "550 5.5.0 Requested action not taken: mailbox unavailable (S2017062302). [DB8EUR06FT018.eop-eur06.prod.protection.outlook.com]\n"
      },
      "mail_host": "104.47.22.161",
      "port_opened": true
    }
  ],
  "success": false,
  "validation_type": "smtp"
}