On 4/24/2011 10:29 PM, Jerry wrote:
I am not even sure if this is possible. I cannot find an example of it anywhere.
I am in the process of setting up a "plus" addressing system. The addresses would be addresses to accounts like <sales+USERNAME@domain.com>. there are presently 50 such names in sales.
This is the one line entry I presently have in the sieve script:
if envelope :detail "To" "joe" {fileinto "joe"; stop;}
Now, what I would like to do is find a way to do this:
if envelope :detail "To" "joe" {fileinto :detail; stop}
That does not work though. I really do not want to list every available user individually since it will eventually become a nightmare to maintain. Is there any way in a sieve script to assign the value of ":detail" to another variable and use that variable in the "fileinto" portion of the script? I would also need to maintain the same case folding so as not to create multiple folders with the same name; ie, Joe, joe, jOe
The variables extension is what you need. Here's an example:
require ["variables", "envelope", "fileinto", "subaddress"];
if envelope :is :user "to" "sales" { if envelope :matches :detail "to" "*" { /* Save name in ${name} in all lowercase except for the first letter. * Joe, joe, jOe thus all become 'Joe'. */ set :lower :upperfirst "name" "${1}"; }
if string :is "${name}" "" {
/* Default case if no detail is specified */
fileinto "sales";
} else {
/* For sales+joe@ this will become users/Joe */
fileinto "users/${name}";
}
}
Regards,
Stephan.