public function onAfterSendMail( mixed $result, Mail $mailmixed $transporter, object $options ) : void

Fires after VikRestaurants tried to deliver an e-mail.


Description

It is possible to use this hook to track the stability of the e-mail transporter.

This hook is fired even if the onBeforeSendMail thrown an exception.


Parameters

$result

(bool|Exception)  Whether the e-mail was delivered or not. An exception in case of mailing configuration error or whether the onBeforeSendMail hook manually thrown it to abort the sending process.

$mail

(Mail)  Encapsulates the e-mail information. This class is part of the E4J\VikRestaurants\Mail namespace.

$transporter

(mixed)  The instance used by the CMS to dispatch e-mail notifications.

$options

(object)  A configuration registry. Only the following attributes are used in this context.

  • silent (bool) - True to ignore any thrown exception and go ahead without breaking the process (false by default).
  • admin (bool) - True to enqueue a system message in case of errors (false by default). Applies only in case of silent delivery.

Example

/**
 * Fires after delivering an e-mail.
 * 
 * @param   mixed   $result       Whether the delivery succeeded or not.
 * @param   Mail    $mail         The e-mail information.
 * @param   mixed   $transporter  The e-mail transporter.
 * @param   object  $options      The configuration registry.
 * 
 * @return  void
 */
public function onAfterSendMail($result, $mail, $transporter, $options)
{
    if ($result instanceof Exception) {
        // prevent the system from breaking the whole process
        $options->set('silent', true);

        if (JFactory::getUser()->authorise('core.admin', 'com_vikrestaurants')) {
            // we have an administrator, display the error as system message
            $options->set('admin', true);
        }
    }
}

Changelog

Version Description
1.9 Introduced.
Last Update: 2023-12-29 14:15
Helpful?
See Also: