Since the last update to Avast Antivirus, I can no longer connect to POP3 e-mail servers using my own Java program. Mozilla Thunderbird works fine, and I can also connect using PuTTY (raw, port 110).
Connecting to other ports than 110 works fine. When the following code is run:
try
{
System.out.println("Connecting to www.google.com:80");
java.net.Socket socket1 = new Socket("www.google.com", 80);
System.out.println("Connected");
socket1.close();
System.out.println("Connecting to pop01.binero.se:110");
java.net.Socket socket2 = new Socket("pop01.binero.se", 110);
System.out.println("Connected");
socket2.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
it outputs:
Connecting to www.google.com:80
Connected
Connecting to pop01.binero.se:110
java.net.ConnectException: Connection refused: connect
at java.base/java.net.PlainSocketImpl.connect0(Native Method)
at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:591)
at java.base/java.net.Socket.connect(Socket.java:540)
at java.base/java.net.Socket.<init>(Socket.java:436)
at java.base/java.net.Socket.<init>(Socket.java:213)
at SocketTest.main(SocketTest.java:15)
If I disable Avast MailShield for incoming mail, I can connect using the above code. As far as I know, MailShield intercepts the TCP connection from e-mail clients and scans any e-mail attachments. If it finds a virus, it adds an alert text to the e-mail subject.
What I don’t understand is how it intercepts the TCP connection, how it distinguishes between my program, Thunderbird or PuTTY and why it blocks only my program.
I would like to keep MailShield activated for Thunderbird, and either disable it for my own program or make Avast recognize my program as a valid e-mail client and let it through.