-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (42 loc) · 868 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"bufio"
"fmt"
emailverifier "github.com/AfterShip/email-verifier"
"github.com/panjf2000/ants/v2"
"os"
"regexp"
"strings"
"sync"
)
var (
verifier = emailverifier.
NewVerifier().
EnableSMTPCheck()
)
func main() {
defer ants.Release()
var wg sync.WaitGroup
p, _ := ants.NewPoolWithFunc(100, func(i interface{}) {
input := i.(string)
emailRegex := `\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b`
re := regexp.MustCompile(emailRegex)
email := re.FindString(input)
split := strings.Split(email, "@")
domain := split[1]
username := split[0]
ret, _ := verifier.CheckSMTP(domain, username)
if ret.Deliverable {
fmt.Println(input)
}
wg.Done()
})
defer p.Release()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
wg.Add(1)
input := scanner.Text()
p.Invoke(input)
}
wg.Wait()
}