1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 17:18:50 -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,26 +182,28 @@ 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 (localAddress instanceof Inet6Address) if (!ipAddr.equals(""))
{ {
localHost = "[IPV6:" + ipAddr + "]"; if (localAddress instanceof Inet6Address)
{
localHost = "[IPV6:" + ipAddr + "]";
}
else
{
localHost = "[" + ipAddr + "]";
}
} }
else else
{ {
localHost = "[" + ipAddr + "]"; // If the IP address is no good, set a sane default (see issue 2750).
localHost = "android";
} }
} }
// If we don't have a hostname for whatever reason, set a sane default (see issue 2750).
if (localHost.equals(""))
{
localHost = "android";
}
List<String> results = executeSimpleCommand("EHLO " + localHost); List<String> results = executeSimpleCommand("EHLO " + localHost);
m8bitEncodingAllowed = results.contains("8BITMIME"); m8bitEncodingAllowed = results.contains("8BITMIME");