Skip to content

Spontaneous eMails

tomolimo edited this page Oct 7, 2020 · 7 revisions

How to use this feature

Using the GLPI_SEND_EMAIL case variable (see: Case Variables) anywhere in a process, will trigger an email (or several emails) at the next case derivation (case going from one task to another one)

This case variable must contains a JSON string that is the representation of an array which defines a list of notification id that are going to be used as email templates. And for each notification id, a list of recipients who are going to receive the emails.

GLPI_SEND_EMAIL usage

To give an example of the case variable usage: Here is an example of a portion of code (to be used in a trigger):

@@GLPI_SEND_EMAIL = json_encode([
	['notifications_id' => 267, 'recipients' => '[email protected]'], 
	['notifications_id' => 268, 'recipients' => [937, 240, '[email protected]']]
	]);

This portion of code will permit to send 4 emails:

  • one email to [email protected] using notification id 267
  • three emails with notification id 268: one to GLPI user with id 937, one to GLPI user with id 240, and one to [email protected]

Note: when sending an email, the plugin will use the notification template matching the user's language defined in the user settings. If not available, it will use the default notification template translation. This schema is the default GLPI behavior. Of course, if the notification has to be done to an email address (and not a GLPI user, in our example to [email protected]) the plugin will use the default GLPI language.