All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.subethamail.smtp.test.util.Practice Maven / Gradle / Ivy

There is a newer version: 3.1.7
Show newest version
package org.subethamail.smtp.test.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.subethamail.wiser.Wiser;

/**
 * A simple command-line tool that lets us practice with the smtp library.
 *
 * @author Jeff Schnitzer
 */
public class Practice
{
	/** */
	@SuppressWarnings("unused")
	private final static Logger log = LoggerFactory.getLogger(Practice.class);

	/** */
	public static final int PORT = 2566;

	/** */
	public static void main(String[] args) throws Exception
	{
		Wiser wiser = new Wiser();
		wiser.setHostname("localhost");
		wiser.setPort(PORT);

		wiser.start();

		String line;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		do
		{
			line = in.readLine();
			line = line.trim();

			if ("dump".equals(line));
				wiser.dumpMessages(System.out);

			if (line.startsWith("dump "))
			{
				line = line.substring("dump ".length());
				File f = new File(line);
				OutputStream out = new FileOutputStream(f);
				wiser.dumpMessages(new PrintStream(out));
				out.close();
			}
		}
		while (!"quit".equals(line));

		wiser.stop();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy