Hello,
I would like to add a prefilter in front of a mailbox that, among other things, sends the mail at the same time (or sends it back to the sender via reject; depending on whether the sender is approved for sending or not) and then sorts it into an appropriate folder.
For this purpose I have currently implemented the following solution:
require ["fileinto", "imap4flags", "reject"];
if address :is "to" "mailinglist1@mydomain.org" {
if anyof (
address :is "from" "allowedsender@domain1.org",
address :is "from" "allowedsender@domain2.org",
address :is "from" "allowedsender@domain3.org"
) {
redirect "recipient@somedomain1.org";
redirect "recipient@somedomain2.org";
redirect "recipient@somedomain3.org";
addflag "ok";
addflag "List1";
keep;
} else {
reject "It is not allowed to send from your Mailaccount to the mailinglist1";
addflag "failed";
addflag "List1";
keep;
}
} elsif address :is "to" "mailinglist2@mydomain.org" {
if anyof (
address :is "from" "allowedsender@domain4.org",
address :is "from" "allowedsender@domain5.org",
address :is "from" "allowedsender@domain6.org"
) {
redirect "recipient@somedomain4.org";
redirect "recipient@somedomain5.org";
redirect "recipient@somedomain6.org";
addflag "ok";
addflag "List2";
keep;
} else {
reject "It is not allowed to send from your Mailaccount to the mailinglist1";
addflag "failed";
addflag "List2";
keep;
}
}
This construct works quite well. But it does not yet sort the mails into subfolders. As soon as I try this e.g. with fileinto "INBOX.list1";
the mail is no longer forwarded and moreover it then lands in the inbox (but not in the subfolder “list1” / I had of course already created this folder before).
Does anyone have an idea how I could fix this?
I could live as it is currently, but it would be nicer with the subfolders…