3

Is there a way to block a local/unix user (or a list of local users) from sending mails via mail command (or maybe even in postfix, which is the MTA I have).

  • 2
    You probably want to take a look at Postfix restriction classes. – Karol Babioch Mar 19 '14 at 23:27
  • @KarolBabioch Ok, I did the following and yet I'm still able to send with the local unix user "gitolite": pastebin.com/bN46U7mr I also restarted postfix. What is wrong? – alexandernst Mar 19 '14 at 23:56
  • @KarolBabioch btw, just realized that there is a missing comma after the hash:<path> line. I fixed that but it's still not working. And by "not working" I mean I can "su gitolite" and then "mail -s Test foo@bar.com" and the mail gets to the queue. – alexandernst Mar 20 '14 at 0:02
  • Can you paste the loglines generated by postfix after the mail command is run? – clement Mar 20 '14 at 6:06
  • Ah, your comment actually lead me to the solution :) I forgot to generate the .db file with postmap. Thank you! – alexandernst Mar 20 '14 at 10:01
3

As suggested by @Gilles, I'm leaving here what I did so others can benefit from it.

My machine's host is abcxyz.ovh.net and the user I was trying to block was foobar.

I ended up creating /etc/postfix/sender_access with the following content:

foobar@abcxyz.ovh.net REJECT

Then I compiled it with postmap /etc/postfix/sender_access.

Finally, I added this to my Postfix configuration:

smtpd_recipient_restrictions =
 check_sender_access hash:/etc/postfix/sender_access,
 ...,
 ...,
 ...,
 ...
  • It works for local users, but it doesn't work for users sending mail connecting localhost:25. – peterh Aug 8 '18 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.