When Running GUI Application From NetBeans IDE Everything going well, and mails are sending without any issue but when clean and build a jar file i cant send any mails NOTE: without any exception
CODE:
public void sendVerificationMail( String To, String name, String group, String pass) {
Thread t = new Thread() {
@Override
public void run() {
try {
String to = To;
String from = user_name;
String host = "smtp.gmail.com";
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", "465");
properties.put("mail.smtp.ssl.enable", "true");
properties.put("mail.smtp.auth", "true");
//properties.put("java.net.preferIPv4Stack", "true");
Session session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user_name, user_pass);
}
}
);
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Verification-Code");
message.setText("Hello, " + name + "
" + "Your Code is : " + pass + " ,"
+ "Please Use It For Login Purpose" + "
" + "Best Regards!" + "
" + "Eng: Hamdy Elasawy
"
+ "RPA Developers Group #: " + group);
Transport.send(message);
} catch (Exception e) {
// JOptionPane.showMessageDialog(null, e);
}
}
};
t.start();
}
Using:
-NetBeans IDE
-JDK 8
Thanks
question from:
https://stackoverflow.com/questions/65877018/cannot-send-java-mail-using-jar-file-after-clean-and-building-netbeans-jdk8 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…