18 package org.turro.elephant.james;
20 import java.io.BufferedReader;
21 import java.io.BufferedWriter;
22 import java.io.InputStream;
23 import java.io.InputStreamReader;
24 import java.io.OutputStream;
25 import java.io.OutputStreamWriter;
26 import java.net.Socket;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import org.turro.elephant.context.ElephantContext;
37 private String mailHost, user, password;
41 this.mailHost = mailHost;
44 this.password = password;
48 String returnString =
"An unknown error has occurred.";
50 Socket socket =
new Socket(mailHost, port);
51 InputStream is = socket.getInputStream();
52 InputStreamReader isr =
new InputStreamReader(is);
53 BufferedReader br =
new BufferedReader(isr);
54 OutputStream os = socket.getOutputStream();
55 OutputStreamWriter osw =
new OutputStreamWriter(os);
56 BufferedWriter bw =
new BufferedWriter(osw);
60 String infoString =
"OK: \r\n\r\n";
62 while ((line = br.readLine()) !=
null) {
65 if (line.indexOf(
"id") != -1) {
70 }
else if (line.indexOf(
"Password") != -1) {
76 if (line.indexOf(
"Welcome") != -1) {
90 infoString += br.readLine() +
"\r\n";
101 returnString = (String) infoString;
108 catch (Exception e) {
109 if (command.
getCommand().equals(
"shutdown")) {
110 returnString =
"OK: Shutdown";
static String logMsg(String msg)
String execute(JamesCommand command)
JamesRemoteManager(String mailHost, int port, String user, String password)