Before Send Employee
public function onBeforeQuickContactSend(int $id_employee, string &$subject, string &$content, bool &$is_html, array &$sender, array &$recipients, JModelVAP $model) : bool
Fires while before sending an e-mail to the employee through the Quick Contact feature.
Description
Trigger event to allow the plugins to manipulate quick contact messages for the given employee.
It is possible to throw an exception to avoid sending the e-mail. The exception text will be used as error message.
This hook can be used, in example, to ban certain e-mail/IP addresses or to forward the same message to several recipients.
Parameters
- $id_employee
-
(int) The ID of the employee to notify.
- &$subject
-
(string) The subject of the e-mail, by default equals to "New Quick Contact".
- &$content
-
(string) The content of the e-mail, which is equals to the message wrote by the customer.
- &$is_html
-
(bool) True in case the content of the e-mail includes HTML tags (always
false
by default). Useful in case a plugin needs to include HTML tags to the body. - &$sender
-
(array) An associative array containing the
name
and theemail
of the customer. In case the mail is configured to send messages only by a specific domain, than it is appropriate to alter theemail
attribute and to include the mail address of the customer within the body. - &$recipients
-
(array) An array containing all the mail addresses to notify. By default, the array contains only the e-mail of the employee.
- $model
-
(JModelVAP) The model responsible of sending the e-mail.
Return Value
Boolean. True to send the message, false to deny it.
Example
/**
* Trigger event to allow the plugins to manipulate quick contact messages for the given
* employee. It is possible to throw an exception to avoid sending the message.
* The exception text will be used as error message.
*
* @param integer $id_employee The employee ID.
* @param string &$subject The e-mail subject.
* @param string &$content The e-mail content (the customer message).
* @param boolean &$is_html True if the e-mail should support HTML tags.
* @param string &$sender The e-mail sender details (added @since 1.7).
* @param array &$recipients A list of recipient e-mails (added @since 1.7).
* @param JModel $model The current model (added @since 1.7).
*
* @return boolean True to send the message, false to deny it.
*/
public function onBeforeQuickContactSend($id_employee, &$subject, &$content, &$is_html, &$sender, &$recipients, $model)
{
// include customer details at the beginning of the body
$content = sprintf("E-mail sent by %s (%s)\n\n", $sender['name'], $sender['email']) . $content;
// overwrite sender details
$sender['email'] = 'info@mydomain.com';
// always forward the e-mail to the address of the moderator
$recipients[] = 'moderator@mydomain.com';
return true;
}
Changelog
Version | Description |
---|---|
1.7 | Added $sender , $recipients and $model arguments.Accepted a return value to abort the sending process. |
1.6 | Introduced. |