gradle java邮件bot dosent工作,因为已完成非零退出代码1

pinkon5k  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(481)

所以我用javax.mail(gradle)制作了一个java邮件机器人
经过几个小时的调试,我得到了依赖性的工作
但我现在犯了这个错误
我正在使用JDK11
intellij idea终极版2020.2.3

  1. > Process 'command 'C:/Program Files/Java/jdk-11.0.8/bin/java.exe'' finished with non-zero exit value 1

这不允许我运行main.main()
这是code-build.gradle

  1. id 'java'
  2. }
  3. group 'com.putopug.mailerdeamon'
  4. version 'DAEMON'
  5. repositories {
  6. mavenCentral()
  7. }
  8. dependencies {
  9. testCompile group: 'junit', name: 'junit', version: '4.12'
  10. //compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
  11. //compile 'javax.mail:javax.mail-api:1.6.2'
  12. compile group: 'javax.mail', name: 'mail', version: '1.5.0-b01'
  13. }

主.java

  1. import javax.mail.*;
  2. import javax.mail.internet.*;
  3. import java.io.Console;
  4. import java.util.Properties;
  5. public class Main {
  6. public static void main(String[] args) throws MessagingException {
  7. Properties prop = new Properties();
  8. prop.put("mail.smtp.auth", true);
  9. prop.put("mail.smtp.starttls.enable", "true");
  10. prop.put("mail.smtp.host", "smtp.gmail.com");
  11. prop.put("mail.smtp.port", "465");
  12. prop.put("mail.smtp.ssl.trust", "smtp.gmail.com");
  13. Session session = Session.getInstance(prop, new Authenticator() {
  14. @Override
  15. protected PasswordAuthentication getPasswordAuthentication() {
  16. return new PasswordAuthentication("gemail", "ddddddd");
  17. }
  18. });
  19. Message message = new MimeMessage(session);
  20. message.setFrom(new InternetAddress("email"));
  21. message.setRecipients(
  22. Message.RecipientType.TO, InternetAddress.parse("email"));
  23. message.setSubject("Mail Subject");
  24. String msg = "This is my first email using JavaMailer";
  25. MimeBodyPart mimeBodyPart = new MimeBodyPart();
  26. mimeBodyPart.setContent(msg, "text/html");
  27. Multipart multipart = new MimeMultipart();
  28. multipart.addBodyPart(mimeBodyPart);
  29. message.setContent(multipart);
  30. Transport.send(message);
  31. }
  32. }
kq0g1dla

kq0g1dla1#

我只需要用try-catch循环来包围代码

相关问题