The right way to prevent specific users from sending emails

Hello everyone,
After countless searches on the forum and on the Internet. I need a solution to block one user or more to sending emails from the server. I saw that there is a solution with iptables, in my opinion it is less suitable. I think the most correct way would be by exim acl? It is important to block at the server level and not by a file at the root of the site so that they cannot cancel the block or know that it exists.
Every attempt I made ended in failure. The reason is that there are users whose website (usually wordpress) is full of garbage and they are not interested in fixing the problem, so I have no choice but to block the sending of emails from the server and this to protect myself from getting blacklisted.
The sending is via a PHP script/contact form of one or another plugin.
I would appreciate recommendations on the best way to do this.
Thanks in advance

Easiest method is to block the use of mail function

And force users to connect smpt via phpmailer / other script

How would you recommend to do it via user.ini?

disabled_functions can’t b used in .user.ini so Changes in php.ini is required

php.ini in the public_html ?

No /etc/php/x.x/fpm/php.ini and /etc/php/x.x/cli/

1 Like

Thanks @eris ! How would you set the function for specific user?

You can’t … That is why they should authenticate via SMTP when they use PHPmail er or any Wordpress plugin…

1 Like

Well I prefer not breaking up the other users websites.

You don’t have to break other user’s sites, but the other users will need to ensure that they are using authenticated SMTP. On shared hosting they should all be doing that already for security and accountability reasons.

You’re right about the better security thing. But that’s exactly what I want to avoid, Force all the users websites to setup smtp auth.
And this is not helping me with new websites that will send out spam messages.