private void btn_mailActionPerformed(java.awt.event.ActionEvent evt) { Properties pro = new Properties(); pro.put("mail.smtp.host","smtp.gmail.com"); pro.put("mail.smtp.socketFactory.port","465"); pro.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLServerSocketFactory"); pro.put("mail.smtp.auth","true"); pro.put("mail.smtp.port","465"); Session session = Session.getDefaultInstance(pro, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("abc@gmail.com","abc") ; } } ); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("abc@gmail.com")); message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("xyz@gmail.com")); message.setSubject("Test Mail"); message.setText("Hello how are you???"); Transport.send(message); JOptionPane.showMessageDialog(null, "Send"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)