Routing based on the sender address
This tutorial explains how incoming emails can be specifically routed based on the sender. This is particularly useful if, for example, there is only one central service address such as "support@myservice.de", but the incoming emails are to be distributed to different teams.
In the following example, we will distribute emails from the sender "*@somecompany.com" to the group with ID 25 and those from the sender "*@anothercompany.com" to the group with ID 26.
To do this, please start todo4teams and log in as “Admin” or “Superadmin”, depending on your user rights. Only as a user with administrator rights can you edit and manage email inboxes.
Go to the Mailboxes menu item and click on the email address you want to configure in a line. The dialog for editing the corresponding mailbox opens automatically.
In the "Scripts" tab, select the "Receive action" to create the corresponding script. Please paste the following script into the top text box.
if(senderAddress.indexOf('@somecompany.com')>-1){
helper.routeToGroup(25);
} else if (senderAddress.indexOf('@anothercompany.com')>-1){
helper.routeToGroup(26);
}
Please change the domain name and group IDs according to your needs. Click on "Save" and you can check whether the internal distribution works by sending messages from different senders to your central email address. The rules according to which incoming emails are distributed can be freely defined. You can extend the example rule above as you wish.
In this context, it would be a useful addition, for example, to check the validity of a sender address using the indexOf method: e.g.:. The sender in the header could be written as "john.doe@somecompany.com" or something like "Doe, John <john.doe@somecompany.com>.
Please note: Emails from all other senders are routed in the "Basic Data" according to the global email access setting. Please always define the correct basic setting there!
In the above script we used the helper.routeToGroup() method and defined the group IDs as parameters. In addition, the helper.routeToGroupByName() method could also be used, which reads the group name directly. In principle, however, it is better to use the first method mentioned, as it is much more stable against, for example, renaming of groups or possible typos.