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

11 error validating email via smtp helo failed #12

Merged
merged 2 commits into from
Aug 9, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ go.work.sum
.env

.idea/
mailsherpa
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<br /><br />

<p align="center"><img align="center" src="https://customer-os.imgix.net/companies/logos/mailsherpa_logo.png" height="144" alt="mailsherpa" /></p>
<p align="center"><img align="center" src="https://customer-os.imgix.net/companies/logos/mailsherpa_logo.png" height="200" alt="mailsherpa" /></p>
<h1 align="center">MailSherpa</h1>
<h4 align="center">A CLI for verifying email address deliverability over SMTP without sending an email.</h4>

Expand Down
2 changes: 2 additions & 0 deletions internal/dns/known_email_providers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ domains = [
["163.com", "netease"],
["263.net", "263"],
["263xmail.com", "263 xmail"],
["antispameurope.com", "hornetsecurity"],
["daum.net", "daum"],
["gmx.net", "gmx"],
["haihaimail.jp", "haihai mail"],
["hornetsecurity.com", "hornetsecurity"],
["hushmail.com", "hushmail"],
["icloud.com", "icloud"],
["mail.ru", "mailru"],
Expand Down
23 changes: 19 additions & 4 deletions internal/mailserver/mailserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,26 @@ func connectToSMTPviaProxy(mxServer, proxyAddress, proxyUsername, proxyPassword
}

func readSMTPgreeting(smtpClient *bufio.Reader) error {
_, err := smtpClient.ReadString('\n')
if err != nil {
return fmt.Errorf("Failed to read SMTP server greeting: %w", err)
for {
line, err := smtpClient.ReadString('\n')
if err != nil {
return fmt.Errorf("Failed to read SMTP server greeting: %w", err)
}

// Trim the line to remove whitespace and newline characters
line = strings.TrimSpace(line)

// Check if this is the last line of the greeting
if strings.HasPrefix(line, "220 ") {
// This is the final greeting line
return nil
} else if !strings.HasPrefix(line, "220-") {
// If the line doesn't start with 220- or 220, it's an unexpected response
return fmt.Errorf("Unexpected SMTP server greeting: %s", line)
}

// If it's a continuation line (starts with 220-), continue reading
}
return nil
}

func sendSMTPcommand(conn net.Conn, smtpClient *bufio.Reader, cmd string) (string, error) {
Expand Down
Loading