$_parameters
$_parameters : array
The parameters to use for the Mail template.
This class contains an email template engine. It can take a template and fill it in with the parameters that have been passed.
E-Mail template language
Three types of variables can be inserted into the email's subject or body. Every value has an associated key, which is searched as array key in the parameter array. Key names are matched case sensitive.
They are identified by "KEY" and are inserted directly.
If you want to pass an array as parameter, ensure that both key and value are convertible to a string by PHP implicitly. Ideally, you have only strings, of course. In the following example, "KEY" refers to the key of the array within the parameter array, and "SUBKEY" refers to the key of a value within the actual array.
Again, you can access the (whole) array using "KEY". In that case you will get a formatted output of all keys and values, consisting of "SUBKEY: VALUE" entries. The value gets word-wrapped and indented automatically at about 76 chars to keep the output easily readable.
If you want to access a specific value from this array, you have to use "__KEY_SUBKEY__" to identify it. This syntax is treated like a string value.
You can pass any object as a value. In this case, the same semantic as with an Array can be used to access the object: "KEY", while "__KEY_SUBKEY" accesses a specific property. Be aware that you need to implement the toString method if you want to output the entire object
Example usage code
$mail = new org_openpsa_mail();
$parameters = array
(
"RESOURCE" => $this->_resource,
"RESERVATION" => $this->reservation,
"ISOSTART" => $this->dm->data["start"]["strfulldate"],
"ISOEND" => $this->dm->data["end"]["strfulldate"],
"LOCALSTART" => $this->dm->data["start"]["local_strfulldate"],
"LOCALEND" => $this->dm->data["end"]["local_strfulldate"],
);
$mail->parameters = $parameters;
$mail->body = $this->_config->get("mail_newreservation");
$mail->to = $email;
if (!$mail->send()) { debug_add("Email could not be sent: " . $mail->get_error_string(), MIDCOM_LOG_WARN); }
This code could for example use a Template subject / body like this:
Subject: New Reservation for __RESOURCE_name__ Your reservation has been received, you will receive a confirmation E-Mail shortly: Start: __ISOSTART__ End: __ISOEND__ __RESERVATION__