Socket smtp = new Socket("localhost", 25);
PrintWriter out = new PrintWriter(smtp.getOutputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(smtp.getInputStream()));
Socket smtp = new Socket("localhost", 25);
PrintWriter out = new PrintWriter(smtp.getOutputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(smtp.getInputStream()));
out.print("X-Mailer: CAcert.org Website\r\n");
// if (array_key_exists("REMOTE_ADDR", $_SERVER)) {
// out.print("X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
out.print("X-Mailer: CAcert.org Website\r\n");
// if (array_key_exists("REMOTE_ADDR", $_SERVER)) {
// out.print("X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
// 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");
// 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");
+ }
- while ((line = in.readLine()) != null && line.matches("\\d+-")) {
- System.out.println(line);
+ while ((line = in.readLine()) != null) {
+ if (line.startsWith(code + " ")) {
+ return true;
+ } else if ( !line.startsWith(code + "-")) {
+ return false;
+ }