ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/util/uk/org/iscream/cms/util/Smtp.java
(Generate patch)

Comparing projects/cms/source/util/uk/org/iscream/cms/util/Smtp.java (file contents):
Revision 1.7 by tdb, Thu Feb 7 17:57:06 2002 UTC vs.
Revision 1.8 by tdb, Fri Feb 8 16:09:27 2002 UTC

# Line 47 | Line 47 | public class Smtp {
47          _socket = new Socket(server, port);
48          _socketIn = new BufferedReader(new InputStreamReader(_socket.getInputStream()));
49          _socketOut = new PrintWriter(_socket.getOutputStream(), true);
50 <        _socketIn.readLine(); // get 220 welcome header
51 <        sendCommand("HELO " + InetAddress.getLocalHost().getHostName(), 250);
50 >        init();
51      }
52  
53   //---PUBLIC METHODS---
# Line 141 | Line 140 | public class Smtp {
140      }
141  
142   //---PRIVATE METHODS---
143 +
144 +    /**
145 +     * Check the server sends a 220 message, and
146 +     * then send our HELO.
147 +     *
148 +     * @throws IOException if something goes wrong
149 +     */
150 +    private void init() throws IOException {
151 +        String temp = _socketIn.readLine();
152 +        // skip over any 220- lines
153 +        while(temp != null && temp.startsWith("220-")) {
154 +            temp = _socketIn.readLine();
155 +        }
156 +        // check if we got a 220 welcome header
157 +        if(temp == null || !temp.startsWith("220 ")) {
158 +            throw new IOException ("Server did not initialise with a 220 message");
159 +        }
160 +        // server gave a 220, it's ok to do a HELO
161 +        sendCommand("HELO " + InetAddress.getLocalHost().getHostName(), 250);
162 +    }
163  
164   //---ACCESSOR/MUTATOR METHODS---
165  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines