on-internet
← Community

java Mail API using to send email from a java program but showing error of SMTP protocol

Stack Overflow ·

public class SendEmail { public static void main(String[] args) { // TODO Auto-generated method stub String to = "[email protected]";//change accordingly String from = "[email protected]";//change accordingly String host = "localhost";//or IP address //Get the session object Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", host); Session session = Session.getDefaultInstance(properties); //compose the message try{ MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO,new InternetAd

Comments

Sign in or sign up to comment and upvote.

No comments yet.