1.1 --- a/src/org/sonews/mlgw/SMTPTransport.java Wed Sep 14 10:47:39 2011 +0200
1.2 +++ b/src/org/sonews/mlgw/SMTPTransport.java Wed Sep 14 23:25:00 2011 +0200
1.3 @@ -21,10 +21,12 @@
1.4 import java.io.BufferedReader;
1.5 import java.io.IOException;
1.6 import java.io.InputStreamReader;
1.7 +import java.io.UnsupportedEncodingException;
1.8 import java.net.Socket;
1.9 import java.net.UnknownHostException;
1.10 import java.util.ArrayList;
1.11 import java.util.List;
1.12 +import org.apache.commons.codec.binary.Base64;
1.13 import org.sonews.config.Config;
1.14 import org.sonews.storage.Article;
1.15 import org.sonews.util.io.ArticleInputStream;
1.16 @@ -65,6 +67,16 @@
1.17 this.socket.close();
1.18 }
1.19
1.20 + private byte[] createCredentials() throws UnsupportedEncodingException {
1.21 + String user = Config.inst().get(Config.MLSEND_USER, "");
1.22 + String pass = Config.inst().get(Config.MLSEND_PASSWORD, "");
1.23 + StringBuilder credBuf = new StringBuilder();
1.24 + credBuf.append(user);
1.25 + credBuf.append("\u0000");
1.26 + credBuf.append(pass);
1.27 + return Base64.encodeBase64(credBuf.toString().getBytes("UTF-8"));
1.28 + }
1.29 +
1.30 private void ehlo(String hostname) throws IOException {
1.31 StringBuilder strBuf = new StringBuilder();
1.32 strBuf.append("EHLO ");
1.33 @@ -91,13 +103,11 @@
1.34 readReply("334");
1.35
1.36 // Send PLAIN credentials to server
1.37 -
1.38 + this.out.write(createCredentials());
1.39 + this.out.flush();
1.40
1.41 - // Read reply
1.42 - String line = this.in.readLine();
1.43 - if (line == null || !line.startsWith("250 ")) {
1.44 - throw new IOException("Unexpected reply: " + line);
1.45 - }
1.46 + // Read reply of successful login
1.47 + readReply("235");
1.48 }
1.49
1.50 private void helo(String hostname) throws IOException {