- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从我的 Java 应用程序向任何特定的电子邮件地址发送电子邮件。我正在使用 Java Mail API,但不幸的是我收到 SMTPSendFailedException 错误。任何人都可以告诉我我在哪里做错了。这是我的代码
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
//import SeconMail.Authenticator;
public class SendMail
{
public static void main(String [] args)
{
// Recipient's email ID needs to be mentioned.
String to = "to@gmail.com";
// Sender's email ID needs to be mentioned
String from = "from@expertflow.com";
// Assuming you are sending email from localhost
String host = "smtp.gmail.com";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.auth", "false");
// Get the default Session object.
Session session = Session.getDefaultInstance(properties);
session.setDebug(true);
try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Now set the actual message
message.setText("This is actual message");
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
最佳答案
properties.setProperty("mail.smtp.user", "abc");
properties.setProperty("mail.smtp.password", "xyz");
properties.setProperty("mail.smtp.auth", "true");
请尝试使用此
关于java - com.sun.mail.smtp.SMTPSendFailedException : 530-5. 5.1 需要身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20780495/
在 JRE 中,Sun 的内部包以 2 个顶级域(sun 和 com)为前缀。例如, com.sun.security.jgss sun.security.jgss 他们选择哪个前缀对我来说似乎很随机
我最近从 Java 8 迁移到了 Java 11。对于 jax.ws 我必须向我的 pom.xml 添加以下外部依赖项,因为它在 Java 11 中不再可用。但是,我遇到了一些论点,即 com.sun
奇怪的是,以下 C++ 程序在 Sun Studio 10 上编译时没有针对 undefined variable 产生警告: int main() { return sun; } sun的值好像
在使用 jhat 分析堆转储时,我观察到创建了许多 DelegatingClassLoader 实例,尽管它们没有在代码中显式调用。我希望这是某种反射优化机制。有人知道细节吗? 最佳答案 是的,这可能
我正在使用 Web 服务在 Android 应用程序和 SOAP Web 服务之间发送数据。此 Web 服务仅接受序列化对象,而执行此操作的唯一方法是使用: import sun.misc.BASE6
我正在将 JDK 版本从 8 更新到 11,以解决某些并发数据结构的问题。 error: type Contended is not a member of package sun.misc [ERR
尝试在两台不同的 Ubuntu 计算机上运行 Android Studio 2.2.3 时,我不断收到此错误。一个运行 14.04 Trusty,另一个运行 16.04 Xenial。 它运行初始屏幕
我有一个具有以下特征的 J2EE 项目: CDI 1.0 Dynamic Web Module 3.0 Java 1.7 (it's being changed to 1.8) JSF 2.0 JPA
JSF 2 的 Mojarra 实现具有以下上下文参数: com.sun.faces.numberOfViewsInSession(默认为 15) com.sun.faces.numberOfLogi
我们有一些代码在使用这个旧的内部 Sun 包来处理图像,本质上是在从输入流中读取/解码后将 JPEG 编码为特定的大小和质量。下面的代码示例。我将不胜感激使用适当的 java.* 或 javax.*
在 go 语言中 spec他们在其中一个示例中使用了三个点: days := [...]string{"Sat", "Sun"} // len(days) == 2 如果省略这三个点有什么不同吗?
我正在使用 jersey 客户端 进行休息调用。我的代码的导入是: import com.sun.jersey.api.client.Client; import com.sun.jersey.api
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 9 年前。 Improve
我们的一个插件需要安装 JDK,而不仅仅是 JRE。我们需要 com.sun.javadoc 和 tools.jar 中的 friend 。我认为 Sun 的许可证不允许重新分发 tools.jar(
起初,我想说这个问题还有其他主题,但我尝试了解决方案,但对我不起作用。 我解释我的问题。我开始在我的电脑上用 Maven 开发一个 Javafx 项目。在这台计算机中,SDK java 是 10。 现
当我这样做时,我收到以下错误 mvn clean deploy -DperformRelease=true [ERROR] Exit code: 1 - .java:3: package javax.
情况: (1) 我正在使用 Android Studio 4.1 并尝试构建示例 Android 应用程序 (2) 我支持代理和代理设置工作正常,因为我能够下载和安装 SDK 我收到以下错误:我尝试了
我在 Linux 上使用 openJDK 11 运行 junit 测试并收到以下错误: java.lang.ClassCastException: class sun.font.CompositeFo
我正在使用 selenium 库进行测试。但下面的代码给了我类转换异常。我已经用谷歌搜索了这个异常,但没有得到解决方案。我对 Https 连接和 http 连接感到困惑。帮我解决这个异常。谢谢 imp
有人知道什么可能导致主题错误吗?我发现了另一个帖子 Enunciate Issue = Assembling the enunciate app. com.sun.tools.apt.mirror.t
我是一名优秀的程序员,十分优秀!