I would like to prevent spam messages sent from my computer by programs/scripts uploaded by anyone.
The only legitimate use case is to connect to postfix through the submission port, and after authentication, submit the email. Postfix will then connect to other mail servers and send it.
I am thinking to use iptables to allow outgoing connections to *:SMTP port if the program trying to open this connection is postfix, and drop any other connection attempts.
I have two questions:
1) How can I identify in iptables, that it is the postfix program that tries to open the connection?
2) How can I prevent a script to invoke sendmail and just give it the message without authentication? Probably this is not that easy, as maybe there are programs, like cron, which try to send email to root@localhost, using sendmail. This should still work.
The system runs Debian stable