We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SmtpClient dispose() in Java

Hi,

We are using Aspose Email for Java in Version 17.2.0.
When sending an email with SmtpClient will call following code.

@Override
public void sendMessage(MailMessage mail) {
	SmtpClient smtpClient = emailConfiguration.getSmtpClient();	
	smtpClient.send(mail);
	smtpClient.dispose();
}

My question is what dispose() method of SmtpClient means in detail and if it is necessary to call in Aspose Java.

Best regards,

Martin

@martin.k,

Thank you for posting your inquiry.

Internal details about dispose() are not available publicly with us. From our knowledge and working with the API, the API finalizes all the operations with the server once this method is called. We will further get information about this method and write back here once available.

@kashif.iqbal

So do you know if it is necessary to call or if email sending would also work withourt calling this method?

Best regards

@martin.k,

Email sending definitely works without calling this method. Email is sent out when SmtpClient.Send is called. The dispose method implements the final things related to the SmtpClient like disconnecting from the server and any other operation that keeps it connected to the email server. It’s like cleaning before your program exits or if you don’t require the client anymore.