Java Mail SMTPClient Example
This Example shows you how to create a SMTP Client using javamail api. A client create new message by using Message subclass. It sets attributes like recipient address and the subject, and inserts the contentinto the Message object, and inserts the content into the Message object. Finally, it sends the Message by invoking the Transport.send() method. The Transport class models the transport agent that routes a message to its destination addresses. This class provides methods that send a message to a list of recipients. Invoking the Transport.send() method with a Message object identifies the appropriate transport based on its destination addresses.
SMTPClient .java
import java.util.*; public class SMTPClient {
public static void main(String args[]) throws Exception {
String host = "192.168.10.205"; // Get system properties // Setup mail server // Get the default Session object. // Create a default MimeMessage object. // Set the RFC 822 "From" header field using the // Add the given addresses to the specified recipient type. // Set the "Subject" header field. // Sets the given String as this part's content, // Send message |
Output:
Message Send..... |