Exim.conf | How to redirect email to another folder?

Posted by rafalmio@reddit | sysadmin | View on Reddit | 0 comments

The problem sounds relatively easy, but I am slowly starting to fry my brain over this :) I am trying to redirect/route incoming emails to another folder depending if they are listed inside the /etc/email\_list file (ON/OFF). I am unsure how would I approach this, I am clearly messing something up. What would be the correct way of approaching this? Thanks! Here are the lines from my exim.conf. It should give you the general idea of what I am trying to do. The Exim documentation is not the best out there, so there might be wrong instructions: custom_folder_redirect: driver = redirect # Check if the email address is listed in /etc/email_list. If yes, folder_redirect = true. condition = ${if exists{/etc/email_list} {${lookup{$local_part@$domain} lsearch{/etc/email_list}}}}} {} set folder_redirect = true message = Your email will be redirected to OTHER_FOLDER folder. #If the folder redirect is OFF, then redirect the mails to INBOX(cur folder) driver = redirect condition = ${if !eq{$folder_redirect}{true}} data = /$home/mail/$domain/$local_part/cur allow_fail file_transport = address_file pipe_transport = address_pipe unseen endif # If the folder redirect is ON, redirect the mails to OTHER_FOLDER condition = ${if eq{$folder_redirect}{true}} data = /$home/mail/$domain/$local_part/OTHER_FOLDER allow_fail file_transport = address_file pipe_transport = address_pipe unseen endif