The JavaMail API is available as an optional package for use with Java SE platform and is also included in the Java EE platform.
99% that you run your tests in SE environment which means what you have to bother about adding it manually to your classpath when running tests.
翻译过来就是:JavaMail API在Java SE 平台是可选的,在Java EE 平台是自动包含的,你很有可能是Java SE的环境,因此,需要手动导包。
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.3</version>
</dependency>
这两个包一个都不能少,特别是第二个,往往都是这个包没有导入。