[QUESTION] Emails cannot start with underscore
NicolasSch opened this issue · comments
New bug checklist
- I have updated
truemail
to the latest version - I have read the Contribution Guidelines
- I have read the documentation
- I have searched for existing GitHub issues
Bug description
Hello,
we noticed that emails starting with an underscore are considered invalid by this gem due to the regex check failing. A quick search lead us to the following discussion https://stackoverflow.com/a/9201006 which indicates that leading underscores should be considered valid.
We saw this is not supposed to follow the standard 100% but could the regex be updated? What do you think?
Complete output when running truemail, including the stack trace and command used
Truemail.validate("_foo@example.com")
=>
<Truemail::Validator:
@result=
#<struct Truemail::Validator::Result
success=false,
email="_foo@example.com",
domain="example.com",
mail_servers=[],
errors={:regex=>"email does not match the regular expression"},
smtp_debug=nil,
configuration=
#<Truemail::Configuration:
@blacklisted_domains=[],
@blacklisted_mx_ip_addresses=[],
@connection_attempts=2,
@connection_timeout=2,
@default_validation_type=:mx,
@dns=[],
@email_pattern=/(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w\p{L}.+!~,'&%#*^`{}|\-\/?=$]*)@((?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_fail_fast=false,
@smtp_port=25,
@smtp_safe_check=false,
@validation_type_by_domain={},
@verifier_domain="example.com",
@verifier_email="info@example.com",
@whitelist_validation=false,
@whitelisted_domains=[]>>,
@validation_type=:mx>
Hi, @NicolasSch! Thanks for your request. I think it's not a bug. And default regex it is just my propose. You can configure any behaviour of regex validation you want. Honestly, I've never seen real email addresses that start from special characters.