Sending a MailMessage using SmtpClient class throws Exception

I wanted to update our product from Aspose Email version 23.3 to the latest 23.11 and noticed a problem. Since 23.7, it seems sending a MailMessage with SmtpClient throws an Exception.

Stack-Trace (using version 23.11):

SmtpException: Failure sending mail.
[Ljava.lang.StackTraceElement;@66d3eec0
	at com.aspose.email.zbdm.g(SourceFile:418)
	at com.aspose.email.zbdm.a(SourceFile:222)
	at com.aspose.email.zzv.e(SourceFile:208)
	at com.aspose.email.zzv.a(SourceFile:30)
	at com.aspose.email.zzw.a(SourceFile:46)
	at com.aspose.email.zbit.a(SourceFile:101)
	at com.aspose.email.internal.ah.zd.a(SourceFile:65)
	at com.aspose.email.internal.ah.ze.run(SourceFile:117)

I’m using this code snippet to test the behavior:

        MailMessage message = new MailMessage();
        MailAddressCollection mac = new MailAddressCollection();
        mac.addMailAddress(new MailAddress("..."));
        MailAddressCollection rpt = new MailAddressCollection();
        rpt.addMailAddress(new MailAddress("..."));
        message.setFrom(new MailAddress("..."));
        message.setSender(new MailAddress("..."));
        message.setTo(mac);
        message.setReplyToList(rpt);
        message.setSubject("ASPOSE - Test-Mail");
        message.setBody("");
        message.setHtmlBody("<html><body>This is the Html body</body></html>");
        message.setDeliveryNotificationOptions(DeliveryNotificationOptions.OnSuccess);

        SmtpClient client = new SmtpClient();
        ConfigureSmtpClient(client);
        try {
            client.send(message);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

Same code works with version 23.6 and prior versions. I’m not sure if I’m missing something, but I did not see anything that looks relevant to this in the 23.7 changelog. Can you please investigate this and let me know if I’m doing something wrong?

Hello @arne411,

We have opened the following investigation ticket in our internal issue tracking system:

Issue ID(s): EMAILJAVA-35225

Sorry for the inconvenience.

Hello @arne411,

We have fixed the issue, hotfix 23.11.0.1 prepared

Also you can use a workaround:

//set ReversePath(Return-Path) to "Sender" or "From" email address.
//this address is required if you want any bounce email/error report send to another email other than "Sender" or "From"
message.setReversePath(new MailAddress("..."));

Tested both workaround and hotfix. Issue is resolved in both cases.

Thank you very much for fixing this so fast

@arne411 ,

Thank you for your feedback.

If you have any questions in future, please feel free to ask.