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

update error handling #50

Merged
merged 1 commit into from
Aug 24, 2024
Merged
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
57 changes: 29 additions & 28 deletions mailvalidate/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,39 @@ func handleSmtpResponses(resp EmailValidation) (EmailValidation, MailServerHealt
case "501", "503", "550", "551", "552", "554", "557":
resp.RetryValidation = true

if strings.Contains(resp.Description, "Access denied, banned sender") ||
strings.Contains(resp.Description, "barracudanetworks.com/reputation") ||
strings.Contains(resp.Description, "black list") ||
strings.Contains(resp.Description, "Blocked") ||
strings.Contains(resp.Description, "blocked using") ||
strings.Contains(resp.Description, "envelope blocked") ||
strings.Contains(resp.Description, "ERS-DUL") ||
strings.Contains(resp.Description, "Listed by PBL") ||
strings.Contains(resp.Description, "rejected by Abusix blacklist") {

health.IsBlacklisted = true
ip, err := ipify.GetIp()
if err != nil {
log.Println("Unable to obtain Mailserver IP")
}
health.ServerIP = ip
resp.SmtpSuccess = false
resp.RetryValidation = true
}

if strings.Contains(resp.Description, "user is over quota") ||
strings.Contains(resp.Description, "out of storage") {

resp.IsMailboxFull = true
resp.SmtpSuccess = true
resp.RetryValidation = false
}

if strings.Contains(resp.Description, "Address unknown") ||
strings.Contains(resp.Description, "Bad address syntax") ||
strings.Contains(resp.Description, "cannot deliver mail") ||
strings.Contains(resp.Description, "could not deliver mail") ||
strings.Contains(resp.Description, "doesn't exist") ||
strings.Contains(resp.Description, "dosn't exist") ||
strings.Contains(resp.Description, "I am no longer") ||
strings.Contains(resp.Description, "Invalid address") ||
strings.Contains(resp.Description, "Invalid Recipient") ||
Expand Down Expand Up @@ -316,33 +344,6 @@ func handleSmtpResponses(resp EmailValidation) (EmailValidation, MailServerHealt
resp.RetryValidation = false
}

if strings.Contains(resp.Description, "Access denied, banned sender") ||
strings.Contains(resp.Description, "barracudanetworks.com/reputation") ||
strings.Contains(resp.Description, "black list") ||
strings.Contains(resp.Description, "Blocked") ||
strings.Contains(resp.Description, "blocked using") ||
strings.Contains(resp.Description, "envelope blocked") ||
strings.Contains(resp.Description, "ERS-DUL") ||
strings.Contains(resp.Description, "Listed by PBL") ||
strings.Contains(resp.Description, "rejected by Abusix blacklist") {

health.IsBlacklisted = true
ip, err := ipify.GetIp()
if err != nil {
log.Println("Unable to obtain Mailserver IP")
}
health.ServerIP = ip
resp.SmtpSuccess = false
resp.RetryValidation = true
}

if strings.Contains(resp.Description, "user is over quota") ||
strings.Contains(resp.Description, "out of storage") {

resp.IsMailboxFull = true
resp.SmtpSuccess = true
resp.RetryValidation = false
}
}
return resp, health
}
Expand Down
Loading