java - How can I fix ClassNotFoundException: com.sun.mail.util.MailLogger? -


i want send email, code below

public static void main(string[] args) {      final string username = "emailid@gmail.com";     final string password = "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("from-email@gmail.com"));         message.setrecipients(message.recipienttype.to,             internetaddress.parse("email1@google.com"));         message.setsubject("testing subject");         message.settext("dear mail crawler,"             + "\n\n no spam email, please!");          transport.send(message);          system.out.println("done");      } catch (messagingexception e) {         throw new runtimeexception(e);     } } 

pom.xml

<dependency>     <groupid>javax.mail</groupid>     <artifactid>javax.mail-api</artifactid>     <version>1.5.5</version> </dependency> 

but getting exception

exception in thread "main" java.lang.noclassdeffounderror: com/sun/mail/util/maillogger @ javax.mail.session.initlogger(session.java:230) @ javax.mail.session.<init>(session.java:214) @ javax.mail.session.getinstance(session.java:251) @ com.smart21.spring.utils.mailtest.main(mailtest.java:26) caused by: java.lang.classnotfoundexception: com.sun.mail.util.maillogger @ java.net.urlclassloader.findclass(urlclassloader.java:381) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331) @ java.lang.classloader.loadclass(classloader.java:357) 

try changing from:

<groupid>javax.mail</groupid> 

to:

<groupid>com.sun.mail</groupid> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -