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();