5

What is the maven dependency i should add for

import javax.mail.*;
import javax.mail.internet.*;

Adding the maven dependency from here http://mvnrepository.com/artifact/javax.mail/mail/1.5.0-b01 makes some of the jersey dependencies unable to retrieve error. What do you think is going wrong?

Balaji Vignesh
  • 446
  • 1
  • 7
  • 19
  • The correct answer to this depends upon whether or not you are deploying to a Java EE server, servlet container or building a standalone application. – Steve C Apr 20 '17 at 11:41
  • I am deploying it to a tomcat server – Balaji Vignesh Apr 20 '17 at 11:45
  • In that case @MitulGedeeya 's answer is appropriate, although I'd use version 1.5.6. The linked solution to your download problem is a bit severe though - you normally just need to append `-U` to your maven command line to fix the cached failure problem. In any event that is a different question – Steve C Apr 20 '17 at 12:29
  • @SteveC You are right. Sometimes it won't take dependency from maven but instead it uses cache. So, by putting -U must resolve problem. – Mitul Gedeeya Apr 20 '17 at 13:16
  • @BalajiVignesh Hello, Let us inform whether you resolved problem or not? – Mitul Gedeeya Apr 20 '17 at 17:37

2 Answers2

4

The version 1.6.3 had been the last version of JavaMail; since 2019-07-03, the new name for it is "Jakarta Mail".

Together with the name change also the Maven coordinates got different:

<dependency>
  <groupId>com.sun.mail</groupId>
  <artifactId>jakarta.mail</artifactId>
  <version>…</version>
</dependency>

The project homepage can be found here: https://eclipse-ee4j.github.io/mail/

tquadrat
  • 3,033
  • 1
  • 16
  • 29
  • 1
    just to follow up, with the latest version as for now it'll look like this: com.sun.mail jakarta.mail 2.0.1 – konnovdev Oct 06 '22 at 14:14
3

We are using following dependency:

<dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>javax.mail</artifactId>
</dependency>
Mitul Gedeeya
  • 886
  • 1
  • 10
  • 20
  • I am getting this error on adding com.sun.mail. ArtifactDescriptorException: Failed to read artifact descriptor for com.sun.mail:javax.mail:jar:1.5.2: ArtifactResolutionException: Failure to transfer com.sun.mail:javax.mail:pom:1.5.2 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.sun.mail:javax.mail:pom:1.5.2 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org – Balaji Vignesh Apr 20 '17 at 11:20
  • For that Error [This Link](http://stackoverflow.com/questions/5074063/maven-error-failure-to-transfer) will resolve your issue. – Mitul Gedeeya Apr 20 '17 at 11:24
  • Or You can just check whether in .m2 folder, there will be cached dependency available. just remove that folder and update project. – Mitul Gedeeya Apr 20 '17 at 11:26
  • I have tried removing the folder in the .m2 but facing the same error – Balaji Vignesh Apr 20 '17 at 11:45
  • Hmm. for last time can you please check with the any fixed version of dependency i have given in answer? because we are using the same and our project works. – Mitul Gedeeya Apr 20 '17 at 13:05