通过aspose发送邮件

时间:2016-12-18 17:27:49

标签: java email aspose

我尝试使用aspose发送邮件但是程序的构建一直在运行然后给我错误这是我的代码

 public static void main(String[] args) {
    SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "kerolos", "MyPassword");
    MailMessage message = new MailMessage();
    message.setFrom(new MailAddress("sender@gmail.com"));
    message.getTo().addMailAddress(new MailAddress("reciver@gmail.com"));
    message.setBody("nothinge");
    message.setSubject("me");
    client.send(message);
}

肯定我下载并导入了我需要的所有libarar 这是我的错误

Exception in thread "main" class com.aspose.email.SmtpException: Failure   sending mail. ---> class com.aspose.email.SmtpException: The SMTP server  requires a secure connection or the client was not authenticated. The server  response was: 5.5.1 Authentication Required. Learn more at
5.5.1  https://support.google.com/mail/?p=WantAuthError g73sm13415755wme.16 -  gsmtp

com.aspose.email.abk.f(SourceFile:49)
com.aspose.email.asu.n(SourceFile:130)
com.aspose.email.cg.a(SourceFile:311) 
com.aspose.email.internal.ah.h.a(Unknown Source)
com.aspose.email.internal.ah.j.run(Unknown Source)
java.lang.Thread.run(Thread.java:745)
--- End of inner exception stack trace ---
com.aspose.email.SmtpClient.a(SourceFile:1982)
com.aspose.email.SmtpClient.send(SourceFile:1785) 
test.mina.main(mina.java:23)
at com.aspose.email.SmtpClient.a(SourceFile:1982)
at com.aspose.email.SmtpClient.send(SourceFile:1785)
at test.mina.main(mina.java:23)
Caused by: class com.aspose.email.SmtpException: The SMTP server requires a     secure connection or the client was not authenticated. The server response was:  5.5.1 Authentication Required. Learn more at
5.5.1  https://support.google.com/mail/?p=WantAuthError g73sm13415755wme.16 - gsmtp

com.aspose.email.abk.f(SourceFile:49)
com.aspose.email.asu.n(SourceFile:130)
com.aspose.email.cg.a(SourceFile:311)
com.aspose.email.internal.ah.h.a(Unknown Source)
com.aspose.email.internal.ah.j.run(Unknown Source)
java.lang.Thread.run(Thread.java:745)
at com.aspose.email.abk.f(SourceFile:49)
at com.aspose.email.asu.n(SourceFile:130)
at com.aspose.email.cg.a(SourceFile:311)
at com.aspose.email.internal.ah.h.a(Unknown Source)
at com.aspose.email.internal.ah.j.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)

Java返回:1 建筑失败(总时间:35秒)

1 个答案:

答案 0 :(得分:0)

GMail对于安全性较低的应用程序访问电子邮件有严格的规定。为了允许安全性较低的应用程序访问GMail帐户,您应该通过配置电子邮件帐户来启用访问权限。 https://support.google.com/a/answer/6260879?hl=en

请在最后尝试,如果问题仍然存在,您可以Aspose.Email forum致函我们以获取进一步的帮助。

我与Aspose一起担任开发者布道者。