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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
package formatter
import (
"fmt"
"git.db.org.ai/dborg/internal/models"
"git.db.org.ai/dborg/internal/utils"
)
func FormatEmailResults(response *models.EmailVerifyResponse, asJSON bool) error {
if asJSON {
return utils.PrintJSON(response)
}
PrintSection(fmt.Sprintf("📧 Email Verification: %s", Bold(response.Email)))
statusColor := ColorGreen
switch response.Status {
case "valid":
statusColor = ColorGreen
case "invalid":
statusColor = ColorRed
case "risky", "accept_all":
statusColor = ColorYellow
default:
statusColor = ColorGray
}
fmt.Printf("%s: %s", Cyan("Status"), Colorize(response.Status, statusColor))
if response.Score > 0 {
scoreColor := ColorGreen
if response.Score < 50 {
scoreColor = ColorRed
} else if response.Score < 75 {
scoreColor = ColorYellow
}
fmt.Printf(" (Score: %s)", Colorize(fmt.Sprintf("%d/100", response.Score), scoreColor))
}
fmt.Println()
fmt.Println()
fmt.Printf("%s\n", Bold("Validation Checks"))
checks := []struct {
name string
passed bool
}{
{"Format Valid", response.Regexp},
{"MX Records Found", response.MXRecords},
{"SMTP Server Reachable", response.SMTPServer},
{"Mailbox Verified", response.SMTPCheck},
}
for _, check := range checks {
status := StatusError
if check.passed {
status = StatusSuccess
}
fmt.Printf(" %s %s\n", status.String(), check.name)
}
if response.MXServer != "" {
fmt.Printf("\n%s: %s\n", Cyan("MX Server"), response.MXServer)
}
fmt.Println()
fmt.Printf("%s\n", Bold("Risk Indicators"))
risks := []struct {
name string
present bool
}{
{"Disposable Email", response.Disposable},
{"Webmail Service", response.Webmail},
{"Blocked Domain", response.Block},
{"Gibberish Detected", response.Gibberish},
}
hasRisks := false
for _, risk := range risks {
if risk.present {
hasRisks = true
fmt.Printf(" %s %s\n", StatusWarning.String(), risk.name)
}
}
if !hasRisks {
fmt.Printf(" %s %s\n", StatusSuccess.String(), "No risk indicators found")
}
if response.ResponseTimeMs > 0 {
fmt.Printf("\n%s: %dms\n", Dim("Response Time"), response.ResponseTimeMs)
}
if response.ErrorMessage != "" {
fmt.Printf("\n%s: %s\n", Red("Error"), response.ErrorMessage)
}
if response.VerifiedAt != "" {
fmt.Printf("%s: %s\n", Dim("Verified At"), response.VerifiedAt)
}
return nil
}
|