1

I want to block specific user from sending emails. I tried doing these things which did not help:

  1. Commented user in /etc/passwd
  2. Wrote passwd -l user and restarted sendmail service.

User can't receive mails - that's OK, but they still may send mails. I use Sendmail (port 25) and Dovecot (port 110 POP3).

Any ideas to block a user from sending mails?

  • 1
    The purported duplicate question is about a Posfix system. This question is about, as it says, a Sendmail system. It is not the same answer for both. – JdeBP Aug 8 '18 at 10:09
  • Then it is not dupe. – peterh Aug 8 '18 at 19:55
1

In Sendmail you can add this user to the /etc/mail/access database file (access.db) to disallow them from sending emails:

Put their address in the file /etc/mail/access:

user@my-domain.com REJECT

Then rebuild it:

$ makemap hash /etc/mail/access.db < /etc/mail/access

NOTE: From what I remember you may have to put several permutations of their email address in this file to stop them. so things like user@localhost, etc.

I do not have a sendmail setup handy, but you can typically use a Makefile command that's provided in newer implementations of sendmail.

For more controlling the sending/receiving via Sendmail you can do more specific controls like this in this file:

To:a1@server.vikas.com       REJECT           # Reject a1 user from recieving mails
From:a1@server.vikas.com     REJECT           # Reject a1 user from sending mails

References

  • Is it necessary to rebuild it? I am a little frightened to use makemap command – it dev Aug 8 '18 at 10:22
  • I seem to remember that restarting the sendmail service did this as well. But yeah you typically have to rebuild these files in order for sendmail to use them. BTW I just reinstalled sendmail on CentOS 7 and it does still come with a make command, so you should be able to run that if your setup has it. If you're pensive to do this, back up the whole /etc/mail dir 1st. – slm Aug 8 '18 at 10:23
  • 1
    Good old sendmail...I prefered to deal with it editing .mc files...it would be interesting understanding the problem of the user, blocking users in sendmail wont prevent users/malware scripts form sending email/spam via TCP/25 if the infra-structure allows it. – Rui F Ribeiro Aug 8 '18 at 10:48
  • @slm, may I only restart sendmail service after REJECTING user in access file? Will it help? – it dev Aug 8 '18 at 11:13
  • @itdev - my suggestion was to try doing a restart after adding REJECT entry to see if it triggers a rebuild of access.db, but I'm 90% sure that you have to rebuild these manually using either rehash or the make command. – slm Aug 8 '18 at 11:15

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.