Email batch connection refused by SMTP server

Using Mattermost Professional 7.7.1 with bulk email batch enabled, the SMTP server is refusing connections:

warn [2023-01-31 09:08:02.669 +01:00] Unable to send batched email notification
caller=“email/email_batching.go:350” error=“unable to connect to the SMTP server: 421 4.7.0 Error: too many connections”

Our Postmaster is pointing out that 70+ connections a second from a single IP is blocked on purpose by the server and that the sender should handle this in a better way.

Is there a workaround and/or can Mattermost be improved in that regard?


I heard you’ve already created a ticket with support about this issue and it’s being looked at at the moment, but I think this works as expected on the Mattermost end since there is no kind of connection pooling or reuse in the SMTP client library.
What you could do is you could set up a local MTA on your Mattermost application servers (I’d suggest to use postfix for that) and configure Mattermost to send mails to your local postfix MTA which then in turn forwards all the mails to your current SMTP server (it can even handle SMTP authentication as a client, if that’s what you need to do).
By doing that, you could make use of the Postfix Connection Cache which should work around your SMTP server’s limitation.

Thanks for a possible workaround of this problem. I will try it. Is this documented anywhere that Mattermost does need a MTA in case the SMTP server is configured restrictivly?

I dom‘t think so, but running a local MTA on the application server has multiple advantages, so it‘s actually not really a workaround so to say.