diff --git a/src/net/mail/message.go b/src/net/mail/message.go index 42701f390cc..5679e348f89 100644 --- a/src/net/mail/message.go +++ b/src/net/mail/message.go @@ -751,13 +751,13 @@ func (p *addrParser) consumeDomainLiteral() (string, error) { return "", errors.New("mail: unclosed domain-literal") } + // Check if the domain literal is an IP address if addr, ok := strings.CutPrefix(dtext, "IPv6:"); ok { if len(net.ParseIP(addr)) != net.IPv6len { return "", fmt.Errorf("mail: invalid IPv6 address in domain-literal: %q", dtext) } } else if net.ParseIP(dtext).To4() != nil { - // Check if the domain literal is an IP address return "", fmt.Errorf("mail: invalid IP address in domain-literal: %q", dtext) }