Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateEmail() now supports v3 and v4 #218

Merged
merged 1 commit into from
May 5, 2020

Conversation

thrawn01
Copy link
Contributor

@thrawn01 thrawn01 commented Apr 23, 2020

Purpose

To use the /v4 version of validations define MG_URL in the environment
as https://api.mailgun.net/v4 or set v.SetAPIBase("https://api.mailgun.net/v4")

Implementation

This change is intentionally backward compatible with current code, setting the APIBase suffix to /v3 or /v4 will determine which version will be used. If using /v3then EmailVerification.Reason will be populated by the API. If using /v4 then EmailVerification.Reasons will be populated by the API

Fixes #217

@riskimidiw
Copy link

riskimidiw commented Apr 26, 2020

Thank you for working on this issue. I've checked your mr, but I think we should replace the whole of EmailVerification struct to the latest validation api response (v4), that means in this version we do not support older version api again (v3 or older).

{
    "address": "nonexistentemail@realdomain.com",
    "is_disposable_address": false,
    "is_role_address": false,
    "reason": [mailbox_does_not_exist],
    "result": "undeliverable",
    "risk": "high"
}
{
    "address": "existingemail@realdomain.com",
    "is_disposable_address": false,
    "is_role_address": false,
    "reason": [],
    "result": "deliverable",
    "risk": "low"
}

But if we want to support the older version, I think this MR doesn't solve the problem, because if we use validation api v3, we will get failed unmarshal again, because we cannot unmarshal string (reason type in v3) to array of string (reason type in v4).

@riskimidiw
Copy link

Is there any concern to replace all of response to the latest version sir? because this changes will be breaking changes in the client

@thrawn01
Copy link
Contributor Author

@riskimidiw I was wondering why others have not complained about this, but now that you point out the v3/v4 differences it makes sense. I'll put a bit more time into this today.

@thrawn01 thrawn01 changed the title EmailVerification.reason is now []string ValidateEmail() now supports v3 and v4 Apr 27, 2020
@thrawn01 thrawn01 merged commit 6279ab3 into mailgun:master May 5, 2020
vtopc added a commit that referenced this pull request Feb 6, 2025
IsValid was never populated for v4 validations since
#218

Fixes #385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed unmarshall EmailVerification struct
2 participants