Use IP address for SMTP EHLO if hostname contains invalid characters, e.g. underscore.

Fixes issue 2143
This commit is contained in:
cketti 2010-08-15 19:26:44 +00:00
parent 7964c34dbd
commit ba95150a31

View file

@ -180,17 +180,19 @@ public class SmtpTransport extends Transport
InetAddress localAddress = mSocket.getLocalAddress();
String localHost = localAddress.getHostName();
String ipAddr = localAddress.getHostAddress();
if (localHost.equals(localAddress.getHostAddress()))
if (localHost.equals(ipAddr) || localHost.contains("_"))
{
// We don't have a FQDN, so use IP address.
// We don't have a FQDN or the hostname contains invalid
// characters (see issue 2143), so use IP address.
if (localAddress instanceof Inet6Address)
{
localHost = "[IPV6:" + localHost + "]";
localHost = "[IPV6:" + ipAddr + "]";
}
else
{
localHost = "[" + localHost + "]";
localHost = "[" + ipAddr + "]";
}
}