Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
## [Change log](https://github.com/AfterShip/email-verifier/releases)

Unreleased
----------
* **Breaking**: Remove the non-functional Yahoo API verifier; `EnableAPIVerifier(YAHOO)` and the `YAHOO` constant are gone [#198](https://github.com/AfterShip/email-verifier/pull/198)
* Fix: Yahoo API test panic no longer aborts the test suite [#196](https://github.com/AfterShip/email-verifier/pull/196)

v1.4.0
----------
* Feature: Support Gmail&Yahoo SMTP check by API [#76](https://github.com/AfterShip/email-verifier/pull/88)
* Feature: Support Gmail&Yahoo SMTP check by API [#88](https://github.com/AfterShip/email-verifier/pull/88)
* Optimization: Return HasMXRecord as true when at least one valid mx records exist [#94](https://github.com/AfterShip/email-verifier/pull/94)
* Update Dependencies

Expand Down
4 changes: 0 additions & 4 deletions smtp_by_api.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package emailverifier

const (
YAHOO = "yahoo"
)

type smtpAPIVerifier interface {
// isSupported the specific host supports the check by api.
isSupported(host string) bool
Expand Down
181 changes: 0 additions & 181 deletions smtp_by_api_yahoo.go

This file was deleted.

47 changes: 0 additions & 47 deletions smtp_by_api_yahoo_test.go

This file was deleted.

56 changes: 0 additions & 56 deletions smtp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,6 @@ func TestCheckSMTPUnSupportedVendor(t *testing.T) {
assert.Error(t, err)
}

func TestCheckSMTPOK_ByApi(t *testing.T) {
cases := []struct {
name string
domain string
username string
expected *SMTP
}{
{
name: "yahoo exists",
domain: "yahoo.com",
username: "someone",
expected: &SMTP{
HostExists: true,
Deliverable: true,
},
},
{
name: "myyahoo exists",
domain: "myyahoo.com",
username: "someone",
expected: &SMTP{
HostExists: true,
Deliverable: true,
},
},
{
name: "yahoo no exists",
domain: "yahoo.com",
username: "123",
expected: &SMTP{
HostExists: true,
Deliverable: false,
},
},
{
name: "myyahoo no exists",
domain: "myyahoo.com",
username: "123",
expected: &SMTP{
HostExists: true,
Deliverable: false,
},
},
}
_ = verifier.EnableAPIVerifier(YAHOO)
defer verifier.DisableAPIVerifier(YAHOO)
for _, c := range cases {
test := c
t.Run(test.name, func(tt *testing.T) {
smtp, err := verifier.CheckSMTP(test.domain, test.username)
assert.NoError(t, err)
assert.Equal(t, test.expected, smtp)
})
}
}

func TestCheckSMTPOK_HostExists(t *testing.T) {
domain := "github.com"

Expand Down
18 changes: 8 additions & 10 deletions verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package emailverifier

import (
"fmt"
"net/http"
"time"
)

Expand All @@ -16,7 +15,7 @@ type Verifier struct {
helloName string // email to use in the `MAIL FROM:` SMTP command. defaults to `localhost`
schedule *schedule // schedule represents a job schedule
proxyURI string // use a SOCKS5 proxy to verify the email,
apiVerifiers map[string]smtpAPIVerifier // currently support gmail & yahoo, further contributions are welcomed.
apiVerifiers map[string]smtpAPIVerifier // per-vendor API verifiers; no built-in vendors currently, contributions are welcomed.

// Timeouts
connectTimeout time.Duration // Timeout for establishing connections
Expand Down Expand Up @@ -144,17 +143,16 @@ func (v *Verifier) EnableSMTPCheck() *Verifier {
return v
}

// EnableAPIVerifier API verifier is activated when EnableAPIVerifier for the target vendor.
// EnableAPIVerifier activates an API-based existence check for the given vendor.
// ** Please know ** that this is a tricky way (but relatively stable) to check if target vendor's email exists.
// If you use this feature in a production environment, please ensure that you have sufficient backup measures in place, as this may encounter rate limiting or other API issues.
//
// There are currently no built-in vendors: the Yahoo verifier was removed once its
// endpoint stopped existing (see https://github.com/AfterShip/email-verifier/issues/195),
// following the same fate as the Gmail verifier removed in #113. This remains an
// extension point; contributions adding a working vendor are welcome.
func (v *Verifier) EnableAPIVerifier(name string) error {
switch name {
case YAHOO:
v.apiVerifiers[YAHOO] = newYahooAPIVerifier(http.DefaultClient)
default:
return fmt.Errorf("unsupported to enable the API verifier for vendor: %s", name)
}
return nil
return fmt.Errorf("unsupported to enable the API verifier for vendor: %s", name)
}

func (v *Verifier) DisableAPIVerifier(name string) {
Expand Down
Loading