How to Block an Email Address

What type of hardware are you using: Virtual machine
What YunoHost version are you running: 12.0.16
How are you able to access your server: The webadmin
Are you in a special context or did you perform specific tweaking on your YunoHost instance ?: No.

Describe your issue

I want to block an email address from even hitting my server … not just going to Spam. How can I do this?

Share relevant logs or error messages

na

My research shows this needs to be done at the server level, but I’m not sure what to use in YNH to set the parameters. Any advice or direction would be appreciated!

Hello,

You can’t block an email address from even hitting your server but you can reject it with postfix.

I would use a hook to do that, something like that (i do a quick search, so test it before and do your own research)

/etc/yunohost/hooks.d/conf_regen/20-postfix_blacklist

#!/bin/bash

action=$1
pending_dir=$4
postfix_conf=$pending_dir/../postfix/etc/postfix/main.cf

[[ $action == "pre" ]] || exit 0
[[ -e $postfix_conf ]] || exit 0
sed -i '/smtpd_recipient_restrictions/a\    check_sender_access hash:/etc/postfix/sender_access,' $postfix_conf

Then create your blacklist file and add the blacklist list:

/etc/postfix/sender_access

bad_email@spam.com REJECT
second_bad_email@spam.com REJECT
spam_domain.com REJECT

Create the database :

postmap /etc/postfix/sender_access

And now, you can reload your postfix configuration.

yunohost tools regen-conf postfix --force

2 Likes