Restricting postfix so only existing users can be senders.


I have virtualmin GPL and host a couple of sites.

Earlier this week i noticed that one of my sites had been hacked and used to send spam.
I have locked down the site, cleaned the bad code and installed security patches to fix future problems for that site.

However this might become a problem in the future.

I noticed in the logs that the spam was sent using spoofed users for that virtual domain
and so on.
I have only one valid user on this domain that is able to send email.

Is there a way to restrict postfix so only the actual user can be the sender? (mail from)

Out of the box, at least on CentOS, Postfix only allows outgoing mail from authenticated remote users, and all from localhost. I don’t think there is a way to do specifically what your asking. Except for making sure all users have strong passwords, and no malicious scripts are installed on the server.

What i can see the user is authenticated, but then uses that authentication to send mail from nonexistent users via postfix.

There has to be some setting to restrict this so only the authenticated user can be the sender.

I also saw that spamassasin has an option to scan outgoing mail for spam, this might be one way to at least block some spam mail from leaving the server.
Some more info is here:

Does Virtualmin/Webmin have an option to enable this?