FileDocCategorySizeDatePackage
SMTPExample.javaAPI DocExample1843Wed May 18 09:39:02 BST 2005com.discursive.jccook.net

SMTPExample

public class SMTPExample extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		new SMTPExample().start();
	
public voidstart()

		SMTPClient client = new SMTPClient();
		client.connect("www.discursive.com");
		int response = client.getReplyCode();
		if( SMTPReply.isPositiveCompletion( response ) ) {
			client.setSender( "tobrien@discursive.com" );
			client.addRecipient( "tobrien@iesabroad.org" );
			Writer message = client.sendMessageData();
			message.write("This is a test message" );
			message.close();
			boolean success = client.completePendingCommand();
			if( success ) {
				System.out.println( "Message sent" );				
			}
		} else {
			System.out.println( "Error communicating with SMTP server" );
		}
		client.disconnect();