AfterShip / email-verifier

:white_check_mark: A Go library for email verification without sending any emails.
MIT License
1.18k stars 149 forks source link

Option to Enable/Disable MX Records Check #92

Open fabl3ss opened 1 year ago

fabl3ss commented 1 year ago

We encountered an issue with the CheckMX functionality as it currently lacks a configurable option for disabling this check. It would be highly beneficial to have a similar functionality to that of CheckSMTP, which already implements an option to enable or disable SMTP checks using a bool variable:

func (v *Verifier) CheckSMTP(domain, username string) (*SMTP, error) {
    if !v.smtpCheckEnabled {
        return nil, nil
    }
    // ...
}

To address this limitation, I propose introducing a new field specifically for enabling or disabling MX checks in the Verifier. This approach would align with the existing implementation in CheckSMTP.

For example, the modified code snippet could look like this:

func (v *Verifier) CheckMX(domain string) (*Mx, error) {
    if !v.mxCheckEnabled {
        return nil, nil
    }
    // ...
}

I think it makes sense to set mxCheckEnabled value to true by default, so it won't change current behavior.

I am enthusiastic about contributing to this enhancement if my proposal aligns with your vision.

lryong commented 1 year ago

Hi @fabl3ss Thanks for the business scenarios and suggestions you mentioned, your suggestions are very useful! Feel free to PR 😃