AfterShip / email-verifier

:white_check_mark: A Go library for email verification without sending any emails.
MIT License
1.18k stars 149 forks source link

550 5.5.0 Invalid EHLO/HELO domain #52

Closed klikpaspor closed 2 years ago

klikpaspor commented 2 years ago

package email :

func Split(Email string) (domain string, username string) {
    split := strings.Split(Email, "@")
    domain = split[1]
    username = split[0]
    return
}

func CheckSMTP(Email string) (response string, Error error) {
    verifier := emailverifier.NewVerifier().EnableSMTPCheck()
    domain, username := Split(Email)
    check, error := verifier.CheckSMTP(domain, username)
    if error != nil {
        Error = error
    }

    var json = jsoniter.ConfigCompatibleWithStandardLibrary
    var buffer bytes.Buffer
    var interfaces interface{} = check
    error = json.NewEncoder(&buffer).Encode(&interfaces)
    if error != nil {
        Error = error
    }

    response = buffer.String()

    return
}

package main :

func main() {
c, error := email.CheckSMTP("juragandotid@gmail.com")
    if error != nil {
        print(error.Error())
    } else {
        print(c)
    }

I'm got an error Mail server is unavailable : 550 5.5.0 Invalid EHLO/HELO domain. does mail server block connection to port 25 ?

lryong commented 2 years ago

@klikpaspor Sorry for the slow reply.

No, it seems that the mail server doesn't block your connection, but detailed error is telling you that you have an invalid EHLO/HELO domain.

You can use HelloName() method to set the name in EHLO: SMTP command.

A useful reference: Unable to send emails to this particular domain