}
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 br = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter pw = new PrintWriter(s.getOutputStream())) {
String line;
while ((line = br.readLine()) != null && line.startsWith("220-")) {
// TODO
SimpleDateFormat emailDate = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss ZZZZ (z)", Locale.ENGLISH);
out.print("Date: " + emailDate.format(new Date(System.currentTimeMillis())) + "\r\n");
- out.print("Sender: " + errorsto + "\r\n");
- out.print("Errors-To: " + errorsto + "\r\n");
+ if (errorsto != null) {
+ out.print("Sender: " + errorsto + "\r\n");
+ out.print("Errors-To: " + errorsto + "\r\n");
+ }
if (replyto != null) {
out.print("Reply-To: " + replyto + "\r\n");
} else {