mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
update issue 2744
try all addresses of a host. (Fix is required for proper operation in IPv4-only/IPv6-only networks for IPv4/IPv6 dual-stack mail-hosts)
This commit is contained in:
parent
034f83e522
commit
ba24fdc742
@ -30,6 +30,7 @@ import org.apache.commons.codec.binary.Hex;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SmtpTransport extends Transport
|
public class SmtpTransport extends Transport
|
||||||
@ -152,7 +153,10 @@ public class SmtpTransport extends Transport
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SocketAddress socketAddress = new InetSocketAddress(mHost, mPort);
|
InetAddress[] addresses = InetAddress.getAllByName(mHost);
|
||||||
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
|
try {
|
||||||
|
SocketAddress socketAddress = new InetSocketAddress(addresses[i], mPort);
|
||||||
if (mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED ||
|
if (mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED ||
|
||||||
mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL)
|
mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL)
|
||||||
{
|
{
|
||||||
@ -171,6 +175,15 @@ public class SmtpTransport extends Transport
|
|||||||
mSocket = new Socket();
|
mSocket = new Socket();
|
||||||
mSocket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT);
|
mSocket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
} catch (ConnectException e) {
|
||||||
|
if (i < (addresses.length - 1)) {
|
||||||
|
// there are still other addresses for that host to try
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw new MessagingException("Cannot connect to host", e);
|
||||||
|
}
|
||||||
|
break; // connection success
|
||||||
|
}
|
||||||
|
|
||||||
// RFC 1047
|
// RFC 1047
|
||||||
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
|
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
|
||||||
|
Loading…
Reference in New Issue
Block a user