1 (edited by Twml 2016-04-04 10:34:10)

Topic: block specific email address from sending to my users

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.4
- Linux/BSD distribution name and version: xubuntu 14.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): mysql
- Web server (Apache or Nginx): nginx
- Manage mail accounts with iRedAdmin-Pro? nope
- Related log if you're reporting an issue:
====



how can i block incoming mail from someone who is spamming or bothering my users
say the email is annoying1@gmail.com

obviously dont want to just block gmail.com but the one email from sending to ALL of my users

how can i do this in the most simple way possible? and is it possible to send them back a nice little error note saying their mail was rejected?

i already have a header_checks in postfix to block some attachments with a reject and a notice

how can i block this annoying email sender?
sender_access in postfix? if yes then how please

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: block specific email address from sending to my users

try block it with blacklisting:
http://www.iredmail.org/docs/manage.iredapd.html

3

Re: block specific email address from sending to my users

ZhangHuangbin wrote:

try block it with blacklisting:
http://www.iredmail.org/docs/manage.iredapd.html


tried these replacing the sample with correct info for my server

python wblist_admin.py --add --blacklist 172.16.1.10 user@domain.com
and
python wblist_admin.py --account user@mydomain.com --list --blacklist

neither worked still can get email from the user i specified to test.

4

Re: block specific email address from sending to my users

Do you have plugin "amavisd_wblist" enabled in /opt/iredapd/settings.py?

5

Re: block specific email address from sending to my users

ZhangHuangbin wrote:

Do you have plugin "amavisd_wblist" enabled in /opt/iredapd/settings.py?


I think so it's in my plugins line



# Enabled plugins.
plugins = ["reject_null_sender", "greylisting", "throttle", "amavisd_wblist",

6

Re: block specific email address from sending to my users

Please turn on debug mode in iRedAPD to check why it doesn't work:
http://www.iredmail.org/docs/debug.iredapd.html

7

Re: block specific email address from sending to my users

got it to work and applied the blacklist with

python wblist_admin.py --add --blacklist email@thedomain.com

but its not blocking the emails what its doing is sending them to the users spam boxes
with subject ***SPAM*** (subject here)

i want to outright stop the sending from going through and if possible send back a response to the sender saying it was blocked.

like i did for my attachments when emailed a exe bat ect... it gets blocked fully not going to the inbox and sender gets notified saying attachment blocked email not delivered.

8

Re: block specific email address from sending to my users

here is a sample email postmaster sends back when a disallowed attachment is sent to my mail server:

--
This Message was undeliverable due to the following reason:
Ce message ne peut pas être livré pour la raison suivante:

Your message was not delivered because the destination computer refused
to accept it (the error message is reproduced below).  This type of error
is usually due to a mis-configured account or mail delivery system on the
destination computer; however, it could be caused by your message since
some mail systems refuse messages with invalid header information, or if
they are too large.

Votre message n'a pas été remis parce que l'ordinateur de destination a refusé
de l'accepter (le message d'erreur est reproduite ci-dessous).
Ce type d'erreur est généralement due à un compte mal configuré ou système
de livraison du courrier sur l'ordinateur de destination,
mais il pourrait être causé par votre message, car certains systèmes de messagerie refusent
les messages avec des informations non valide, ou si elles sont trop grandes.

Your message was rejected by domain.com for the following reason:

     5.7.1 Your email contained a disallowed attachment and was not delivered

The following recipients did not receive this message:

     <email@domain.com>

--

this is done with: header_checks in /etc/postfix
/name=[^>]*\.(exe|pif|com|dll|vbs|bat)/   REJECT Your email contained a disallowed attachment and was not delivered

what im trying to do now is block a sender from being able to send emails to my users and if possible give them a responce like above from attachments


and once again:
got it to sort of work and applied the blacklist with
python wblist_admin.py --add --blacklist email@thedomain.com
but its not blocking the emails what its doing is sending them to the users spam boxes
with subject ***SPAM*** (subject here)

i dont want them to get emails from a specific email address at all. needs to be BLOCKED

9 (edited by Twml 2016-04-07 07:30:21)

Re: block specific email address from sending to my users

I got it to work with postfix it fully blocks the sending of the email and it specifies a reason

cd /etc/postfix

nano sender_access
email@domain.com REJECT you are not welcome here
postmap hash:sender_access

nano recipient_access
email@domain.com REJECT you are not welcome here
postmap hash:recipient_access

nano main.cf
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access

/etc/init.d/postfix restart

havnt tested from external yet as i did this on a testbox local but it blocks emails locally from a user like user1@domain1.com to all on domain2.com or all others on domain1.com running on the testbox server it didnt break anything so going to try it on my main mail server see what it does.  ill report back if this fixes my issue or not

Update: IT WORKED! POSTFIX DID IT. it blocks the address fully and sends them back a error saying why here is a output from a bounceback email it sends

--
This Message was undeliverable due to the following reason:
Ce message ne peut pas être livré pour la raison suivante:

Each of the following recipients was rejected by a remote mail server.
The reasons given by the server are included to help you determine why
each recipient was rejected.
Chacun des destinataires suivants a été rejetée par un serveur de messagerie distant.
Les raisons invoquées par le serveur sont inclus pour vous aider à déterminer
pourquoi chaque destinataire a été rejeté.

    Recipient: <sendingto@domain1.com>
    Reason:    5.7.1 <spammer@blockeddomain.com>: Sender address rejected: you are not welcome here
--

would recommend you guys at the iredmail team look into this method i used in case someone else is looking for same solution for blocking a sender. it works perfectly just have to remember to hash files and restart postfix to apply it.

this issue is now SOLVED!

the amavisd_wblist way didnt solve my problem but it was good to know so now i can add senders to users spam inboxes too

10

Re: block specific email address from sending to my users

Twml wrote:

the amavisd_wblist way didnt solve my problem but it was good to know so now i can add senders to users spam inboxes too

"amavisd_wblist" should REJECT the mail directly, not going to spam folder. Looks like you didn't enable iRedAPD integration in Postfix, could you please show us output of command "postconf -n"?

11 (edited by Twml 2016-04-07 23:14:07)

Re: block specific email address from sending to my users

i dont want to change anything on my server its working now the way i want it to, its a clean install all i did was create domain and users then add my smtp relay provider to main.cf in postfix main.cf

do the header_checks to block attachments and now my senders_access to block addresses

havnt done much of anything else. i did try
python wblist_admin.py --add --blacklist mail@domain.ca
but it didnt work it sent to spam so i did
python wblist_admin.py --delete --blacklist mail@domain.ca
to remove it

and have ran this command to fix emails taking 4 hours to arrive in my inbox from some domains

python /opt/iredapd/tools/greylisting_admin.py --disable


attached in a text file is the postconf output

12

Re: block specific email address from sending to my users

It doesn't make sense to me.

*) May i know the content in file /etc/postfix/recipient_access?
*) Could you please try to enable debug mode in iRedAPD and try again? Add a blacklist sender, then send an email from this blacklisted sender. What's the content in /var/log/iredapd/iredapd.log?

13

Re: block specific email address from sending to my users

sender and recipient access files both have entries like this again i take out personal details but format is the same
same thing in both sender and recipient are both pretty much the same just a slightly different error message for well sender vs recipient getting the error.

and have a line commented out with # as its not needed right now just testing and it did work

recipient_access file content:
emailaddress@domain.com REJECT this is the error message they get back if they are blocked
# domain.com REJECT this error message will show to anyone who trys to send from that domain

sent the email from blacklisted user: user1@testdom.com to user2@testdom.com and it went to spam not blocked of user2

attached is the log file for iredapd and a screenshot of user2 inbox

Post's attachments

inbox.png 95.68 kb, file has never been downloaded. 

iredapd.log 6.62 kb, 3 downloads since 2016-04-07 

You don't have the permssions to download the attachments of this post.

14

Re: block specific email address from sending to my users

Check iredapd.log, it says "No wblist found. So there must be something wrong with the SQL data.

2016-04-07 11:48:50 DEBUG --> Apply plugin: amavisd_wblist
2016-04-07 11:48:50 DEBUG Possible policy senders: ['@.', 'user1@testdom.com', '@testdom.com', '@.testdom.com', '@com', '@.com']
2016-04-07 11:48:50 DEBUG Possible policy recipients: ['@.', 'user2@testdom.com', '@testdom.com', '@.testdom.com', '@com', '@.com']
2016-04-07 11:48:50 DEBUG Apply wblist for outbound message.
2016-04-07 11:48:50 DEBUG [SQL] Query local addresses:
SELECT id, email
               FROM users
              WHERE email IN ('@.', 'user1@testdom.com', '@testdom.com', '@.testdom.com', '@com', '@.com')
           ORDER BY priority DESC
2016-04-07 11:48:50 DEBUG Local addresses (in `users`): [(1L, '@.')]
2016-04-07 11:48:50 DEBUG [SQL] Query external addresses:
SELECT id, email
               FROM mailaddr
              WHERE email IN ('@.', 'user2@testdom.com', '@testdom.com', '@.testdom.com', '@com', '@.com')
           ORDER BY priority DESC
2016-04-07 11:48:50 DEBUG Addresses (in `mailaddr`): [(2L, 'user2@testdom.com')]
2016-04-07 11:48:50 DEBUG [SQL] Query outbound wblist:
SELECT rid, sid, wb
               FROM outbound_wblist
              WHERE sid IN (1) AND rid IN (2)
2016-04-07 11:48:50 DEBUG No wblist found.

15 (edited by Twml 2016-04-08 09:36:09)

Re: block specific email address from sending to my users

there is something wrong in your 0.9.4 release then

I just did a fresh install on a VM tried it and same result blacklist applied and it goes to spam not blocking it
take the user off blacklist messages go to inbox.

sender_access
and recipient_access
did the job for me though and i was able to specify a reason for the reject too like with attachments
like i asked for if possible, the blacklist blocking doesnt supply the sender with a reason why it was blocked.

good bit of info for you to know, incase others need the same kind of blocking.
add it to your script of things you say. good info to have.

16

Re: block specific email address from sending to my users

seems there's something wrong with /opt/iredapd/tools/wblist_admin.py, I will try to reproduce this issue later and come back to you with a fix.

17

Re: block specific email address from sending to my users

I cannot reproduce this issue. Here's what i did to reproduce this issue:

*) Add a blacklist sender 'xxx@gmail.com' (mine) on my iRedMail server:

cd /opt/iredapd/tools/
python wblist_admin.py --add --blacklist 'xxx@gmail.com'

*) Send email from 'xxx@gmail.com' to one account on my iRedMail server. I got 'REJECT Blacklisted' error. So it's working as expected.