Ребята хочу отправить песьмо на имейл но у меня на 28 строке исключение Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/MessageRemovedIOException at SendToMail.main(SendToMail.java:28): Что неправильно ?
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
public class SendToMail {
public static void main(String[] args) {
final String username = "******";
final String password = "*******";
Properties prop = new Properties();
prop.put("mail.smtp.host", "smtp.gmail.com");
prop.put("mail.smtp.port", "587");
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true"); //TLS
Session session = Session.getInstance(prop,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("*******"));
message.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse("********")
);
message.setSubject("Testing Gmail TLS");
message.setText("Hello,"
+ "\n\n !");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости