JavaMail API Mac Mail.app链接看起来像x-msg://number/... 在其他情况下,它是垃圾邮件、纯文本等
我不熟悉JavaMail API,但遇到了一个问题。我的发送已经完成,我的代码是:JavaMail API Mac Mail.app链接看起来像x-msg://number/... 在其他情况下,它是垃圾邮件、纯文本等,java,http,email,hyperlink,jakarta-mail,Java,Http,Email,Hyperlink,Jakarta Mail,我不熟悉JavaMail API,但遇到了一个问题。我的发送已经完成,我的代码是: final String username = from; final String password = passwd; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); pro
final String username = from;
final String password = passwd;
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));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipient));
message.setSubject(subject);
message.setContent(content, "text/html");
Transport.send(message);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
我想给内容变量(电子邮件正文)分配一个网页链接。
这将是一封验证电子邮件,用于验证用户的有效性,因此类似于mywebsite.com/user/2341341(生成数字)。
我已经尝试了很多组合
- http://mywebsite.com/user/2341341341
-
等等
该链接在某些情况下显示为蓝色并带下划线,在其他情况下为纯文本(在yahoo mail和gmail works中),在其他情况下,MacOS中的mail.app将其显示为x-msg://234/mywebsite.com/user/2341341341 (看起来像一个链接,但它没有重定向我任何地方),在其他gmail把电子邮件放在垃圾邮件
我想要一个跨平台的解决方案,或者点击这里,或者只是一个用户可以点击的链接
任何帮助都将不胜感激。您是否使用正确的html标记将链接添加到html内容中 关于邮件阅读器的行为,有很多是你无法控制的。你不能控制他们认为是垃圾邮件。您无法控制它们是否允许用户跟踪消息中的链接。你所能做的就是正确格式化你的html文本和链接,确保它不是垃圾邮件