1 package org.cacert.gigi.email;
3 import java.io.DataInputStream;
4 import java.io.DataOutputStream;
5 import java.io.IOException;
6 import java.net.InetAddress;
7 import java.net.ServerSocket;
8 import java.net.Socket;
9 import java.util.Properties;
11 class TestEmailProvider extends EmailProvider {
16 protected TestEmailProvider(Properties props) {
18 servs = new ServerSocket(Integer.parseInt(props
19 .getProperty("emailProvider.port")), 10,
20 InetAddress.getByName("127.0.0.1"));
21 } catch (IOException e) {
26 public synchronized void sendmail(String to, String subject,
27 String message, String from, String replyto, String toname,
28 String fromname, String errorsto, boolean extra) throws IOException {
31 assureLocalConnection();
41 } catch (IOException e) {
46 private void assureLocalConnection() throws IOException {
47 if (client == null || client.isClosed()) {
48 client = servs.accept();
49 out = new DataOutputStream(client.getOutputStream());
50 in = new DataInputStream(client.getInputStream());
54 public String checkEmailServer(int forUid, String address)
56 assureLocalConnection();
57 out.writeUTF("challengeAddrBox");
58 out.writeUTF(address);
62 private void write(String to) throws IOException {
64 out.writeUTF("<null>");