- for (String host : mxhosts) {
- host = host.split(" ", 2)[1];
- if (host.endsWith(".")) {
- host = host.substring(0, host.length() - 1);
- } else {
- return "Strange MX records.";
- }
- try (Socket s = new Socket(host, 25);
- BufferedReader br0 = new BufferedReader(new InputStreamReader(s.getInputStream(), "UTF-8"));//
- PrintWriter pw0 = new PrintWriter(new OutputStreamWriter(s.getOutputStream(), "UTF-8"))) {
- BufferedReader br = br0;
- PrintWriter pw = pw0;
+ String[] parts = address.split("@", 2);
+ String domain = parts[1];
+
+ String[] mxhosts;
+ try {
+ mxhosts = DNSUtil.getMXEntries(domain);
+ } catch (NamingException e1) {
+ return "MX lookup for your hostname failed.";
+ }
+ sortMX(mxhosts);
+
+ for (String host : mxhosts) {
+ host = host.split(" ", 2)[1];
+ if (host.endsWith(".")) {
+ host = host.substring(0, host.length() - 1);
+ } else {
+ return "Strange MX records.";
+ }
+
+ class SMTPSessionHandler {
+
+ public boolean detectedSTARTTLS = false;
+
+ public boolean initiateSMTPSession(BufferedReader r, PrintWriter w) throws IOException {