相关疑难解决方法(0)

来自Maven的JavaMail API

我正在尝试升级到最新的Java Mail实用程序.

<dependency>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
    <version>1.4.7</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

到(我的意图)

<dependency>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
    <version>1.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

但我找不到1.5.1的邮件工件,

但我可以看到

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我的问题是为什么组ID发生了变化,如果我更改了1.5.1的组ID,我是否需要更改已经存在的所有邮件实现(包名更改和其他任何内容)以及com.sun.mailvs 之间的区别是javax.mail什么?

java jakarta-mail maven

40
推荐指数
1
解决办法
2万
查看次数

导入javax.mail无法解析

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;    

private void sendMail() throws MessagingException{

    String host = "smtp.gmail.com";
    String password = "abcde12345";
    String from = "testing@gmail.com";
    String toAddress = email;
    String filename = Environment.getExternalStorageDirectory() + "/jam.jpg";

    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", host);
    properties.put("mail.smtps.auth", true);
    properties.put("mail.smtp.starttls.enable", true);
    Session session = Session.getInstance(properties, null);

    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO, toAddress);
    message.setSubject("Anti-Theft Attachment");

    BodyPart messageBodyPart = new MimeBodyPart(); …
Run Code Online (Sandbox Code Playgroud)

java android

9
推荐指数
1
解决办法
5万
查看次数

标签 统计

java ×2

android ×1

jakarta-mail ×1

maven ×1