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

[BUG] Encoding::UndefinedConversionError in ValidatorJson #120

Closed bestwebua closed 3 years ago

bestwebua commented 3 years ago

New bug checklist

Bug description

With ASCII-8BIT we have binary data, and ruby cant decide, what should be. These chars can exist in some smtp resposes that can lead to Encoding::UndefinedConversionError exception during converting validator result to json in ValidatorJson. Thanks to @eni9889 for report: https://github.com/truemail-rb/truemail-rack/issues/31

Complete output when running truemail, including the stack trace and command used
``` Truemail.validate('abigayle123phil@gnail.com').as_json E, [2020-12-03T20:57:23.599261 #46141] ERROR -- : Truemail smtp validation for abigayle123phil@gnail.com failed (smtp: smtp error) ATTEMPT #1: mail host: 222.73.173.98 port opened: true connection: false errors: rcptto: 550 mailbox abigayle123phil@gnail.com unavailable (���䲻����) connection: server dropped connection after response CONFIGURATION SETTINGS: whitelist validation: false not rfc mx lookup flow: false smtp safe check: false email pattern: default gem value smtp error body pattern: default gem value Encoding::UndefinedConversionError: "\xD3" from ASCII-8BIT to UTF-8 from /Users/user/.asdf/installs/ruby/2.5.0/lib/ruby/gems/2.5.0/gems/truemail-2.2.0/lib/truemail/log/serializer/validator_json.rb:8:in `to_json' ```
bestwebua commented 3 years ago

Done.