sending mail by aspose

647 views Asked by At

i try to send mail using aspose but the build for program is runing for along time then give me errorthis is my code

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

for sure i downloaded and import all libarar that i need this is my error

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 returned: 1 BUILD FAILED (total time: 35 seconds)

1

There are 1 answers

0
Kashif Iqbal On BEST ANSWER

GMail has strict rules for accessing emails by less secure applications. In order to allow GMail account to be accessed by less secure applications, you should enable the access by configuring your email account. https://support.google.com/a/answer/6260879?hl=en

Please try it at your end and if the issue still persists, you can write to us on Aspose.Email forum for further assistance.

I work with Aspose as Developer Evangelist.