1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-13 06:38:05 -05:00

Try using IP address for EHLO if hostname is unavailable. Only use a default hostname if the IP address is unavailable. ref r2958, issue 2750.

This commit is contained in:
Andrew Chen 2010-12-23 17:43:57 +00:00
parent 6c52c8d927
commit 302339545b

View File

@ -182,10 +182,12 @@ public class SmtpTransport extends Transport
String localHost = localAddress.getHostName(); String localHost = localAddress.getHostName();
String ipAddr = localAddress.getHostAddress(); String ipAddr = localAddress.getHostAddress();
if (localHost.equals(ipAddr) || localHost.contains("_")) if (localHost.equals("") || localHost.equals(ipAddr) || localHost.contains("_"))
{ {
// We don't have a FQDN or the hostname contains invalid // We don't have a FQDN or the hostname contains invalid
// characters (see issue 2143), so use IP address. // characters (see issue 2143), so use IP address.
if (!ipAddr.equals(""))
{
if (localAddress instanceof Inet6Address) if (localAddress instanceof Inet6Address)
{ {
localHost = "[IPV6:" + ipAddr + "]"; localHost = "[IPV6:" + ipAddr + "]";
@ -195,12 +197,12 @@ public class SmtpTransport extends Transport
localHost = "[" + ipAddr + "]"; localHost = "[" + ipAddr + "]";
} }
} }
else
// If we don't have a hostname for whatever reason, set a sane default (see issue 2750).
if (localHost.equals(""))
{ {
// If the IP address is no good, set a sane default (see issue 2750).
localHost = "android"; localHost = "android";
} }
}
List<String> results = executeSimpleCommand("EHLO " + localHost); List<String> results = executeSimpleCommand("EHLO " + localHost);