The flag() command is used to mark an email and allows this mark to be queried later.
It can be used to replace X-headers and subject-tags for triggering certain actions.
Structure of the command
flag('name'[,'boolean']);
.
Return value
positive |
if set |
negative |
if not available |
Parameters
name
Specifies the name of the marker. This must be unique.
boolean (optional)
If the parameter is not specified, the value of the marker is read for an if statement.
Possible values
•true, yes or 1 |
Sets the marker |
•false, no or 0 |
Removes the marker |
The default setting is 1 |
Example 1
Line |
Code |
---|---|
01 |
if (!flag('webmail')) { |
02 |
log(1, 'Webmail is not available/activated'); |
03 |
} |
04 |
flag('webmail', 1); |
05 |
if (flag('webmail')) { |
06 |
log(1,'Webmail is activated'); |
07 |
} |
08 |
if (flag('webmail', 0)) { |
09 |
log(1, 'Webmail was active but is now deactivated'); |
10 |
} |
Explanation
In this example, line 01 checks whether the marker webmail is not yet present. Since this was not set before, the return value is positive due to the negation (!) and line 02 is executed. The text Webmail is not available/activated is written into the log.
In line 04 now, the marker webmail is set. In line 05, the marker webmail is queried again. The return value is positive due to setting the flag in line 04, so that the text Webmail is activated from line 06 is written into the log.
In line 08 the marking is queried again and deactivated at the same time. Since the value was still positive at the time of the query and only became negative with the query, the text from line 09 Webmail was deactivated is still written into the log, even if the value is negative afterwards.
This means that with this command, a simultaneous query and setting is possible!