Posts

Showing posts with the label Mail

javax.mail.AuthenticationFailedException: 535 No SMTP server defined. Use real server address instead of 127.0.0.1 in your account.

I am trying to send mail using below program :-  public class mail { public static void main(String[] args) { final String username = "****@gmail.com"; final String password = "****"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props,  new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); }  }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("piyush.mundada89@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("piyush.mundada89@gmail.com...