we have a larger community portal which became bigger and bigger over the years but also has some dead accounts. Recently the ip of the server was blacklisted because many mail adresses of the users are no longer available (550) and the server was sending newsletters to them.
To avoid this i am filtering out known unavailable mailboxes in the sending php script, but i want exim to take over this job because it is more universal.
My plan is to use a mysql database to list the unavailable mailboxes. I want to use a simple script that walks through the logfiles and saves the unavailable mailbox email adresses to the database.
I am not sure if it is common practive that some providers only pretend that mailboxes are unavailable because the server was on the blacklist. But once 40% of the mails were rejected with this response and i can't imagine that so many users deleted their mail accounts. Furthermore i have to take into consideration that deleted accounts could be (re-)created at some time. So along with the address i would store a timestamp that is, lets say 4 weeks in the future. Within this time all mails to the adress have to be dropped. If the first mail after this 4 weeks can be delivered, everything is fine. Otherwise the period should be extended (exponential backoff or so).
I can cover all this with the script and i even know already how a sql query that gives a list of blocked addresses would look like:
SELECT blocked FROM maildrop WHERE name=${localpart}@${domain} and timestamp<UNIX_TIMESTAMP()
But the question is, how do i integrate this into the exim configuration correctly? At first i thought i could use virtual aliases and redirect the mails to devnull@localhost user whose mails are piped to /dev/null.
I tested it using the following configuration
mysql_sys_aliases:
debug_print = "R: mysql_sys_aliases for $local_part@$domain"
driver = redirect
allow_fail
allow_defer
data = ${lookup mysql{SELECT login FROM aliases WHERE alias='${local_part}@${domain}'}}
BTW: I also tested mysql_aliases instead of mysql_sys_aliases
and the following database entry: alias: [email protected] | login: devnull@localhost
But without success. I still received the mails at externaldomain.com
Then i also found this post where acls are used but i couldn't get it working either. Also i am not sure if this works for mail that is sent by the system directly (not via external SMTP) https://serverfault.com/a/577007/239968
How would you solve that?