1package smtp
2
3import (
4 "net"
5)
6
7// AddressLiteral returns an IPv4 or IPv6 address literal for use in SMTP.
8func AddressLiteral(ip net.IP) string {
9 // ../rfc/5321:2309
10 s := "["
11 if ip.To4() == nil {
12 s += "IPv6:"
13 }
14 s += ip.String() + "]"
15 return s
16}
17