RE: Office365 Smtp Thread Limit Exceeded Error

Kleanthis Savva, modified 5 Years ago. New Member Posts: 7 Join Date: 1/10/20 Recent Posts
Hello ,
I have successfully setup office365 account to use for my notifications in liferay portal.
When i do send the notifications i get the following error though :


Unable to send message: 432 4.3.2 STOREDRV.ClientSubmit; sender thread limit exceeded [Hostname=AM7P189MB0993.EURP189.PROD.OUTLOOK.COM]_ [Sanitized]
com.sun.mail.smtp.SMTPSendFailedException: 432 4.3.2 STOREDRV.ClientSubmit; sender thread limit exceeded [Hostname=AM7P189MB0993.EURP189.PROD.OUTLOOK.COM]_ [Sanitized]


Is there any way to reduce the max threads java mail uses ? Or somehow overcome this error ?
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Hard to say. Are you actually sending so many mails at once/parallel? Maybe you could change the office 365 quota?
I am not sure this can be solved in Liferay at all. The problem is that multiple quotas, like max. 150 mails per hour can usually be configured in smtp servers. And tracking and managing those limits is not trivial.
I would probably solve this using a local smtp gateway (in my case postfix because I know it a bit). Liferay -> local smtp -> Office365 SMTP. While I am not postfix expert it should be possible to throttle it. It also automatically retries for a couple of days, so usually all mails should be sent. Of course, the queue might grow and grow, but in that case, a fix will never be possible since you are trying to send more mails than you are allowed too.
Kleanthis Savva, modified 5 Years ago. New Member Posts: 7 Join Date: 1/10/20 Recent Posts
The Actual emails are 43 exactly as many as my Liferay users and error points to smtp threads and not emails per minute to be honest. I think if there is a way for me to limit smtp connections to 1 it will be ok. Can i somehow do this?
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Kleanthis Savva:

The Actual emails are 43 exactly as many as my Liferay users and error points to smtp threads and not emails per minute to be honest. I think if there is a way for me to limit smtp connections to 1 it will be ok. Can i somehow do this?
You can try setting mail.session.jndi.name instead of the individual host/user/password settings and configure the Mail connection through your appserver - there you have all parameters available.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Olaf Kock:

Kleanthis Savva:

The Actual emails are 43 exactly as many as my Liferay users and error points to smtp threads and not emails per minute to be honest. I think if there is a way for me to limit smtp connections to 1 it will be ok. Can i somehow do this?
You can try setting mail.session.jndi.name instead of the individual host/user/password settings and configure the Mail connection through your appserver - there you have all parameters available.
Is there really a mail transport implementation that allows you to limit the number of threads/parallel message? Could be, but I never saw a parameter for that.
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Christoph Rabel:

Is there really a mail transport implementation that allows you to limit the number of threads/parallel message? Could be, but I never saw a parameter for that.
I can neither confirm nor deny. I just can state that if it is configurable, it would rather be there than in Liferay's properties.
Sorry, I didn't check upfront if that is indeed a parameter. But if it isn't configurable here, this would be a strong indicator that the issue is elsewhere and concurrent threadcount is rarely limited.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
I googled the error and it seems to be indeed very uncommon and it looks like a feature of Microsoft.
My best guess is that it isn't configurable at all in javax mail and therefore, it can't be fixed there (except by creating your own mail transport implementation which uses locking)
@OP: Maybe you can change/extend some Liferay class. When you enable debug logging for the Mail related packages like
com.liferay.petra.mail
com.liferay.mail.service
do you see a stacktrace? Maybe some of the classes there can be more or less easily replaced.
If you have a linux server I would set up postfix and route the mail traffic through the local server. That helped me several times before since postfix is very flexible. While it can be a bit overwhelming, just dispatching mails to another smtp server is not really hard to configure.