English (United Kingdom)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Mail  >  After Send

do_action( 'vikrestaurants_after_send_mail', mixed $result, Mail $mailmixed $transporter, object $options )

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 vikrestaurants_before_send_mail 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 vikrestaurants_before_send_mail 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.
 * 
 * @since  1.3
 */
add_action('vikrestaurants_after_send_mail', function($result, $mail, $transporter, $options) {
    if ($result instanceof Exception) {
        // prevent the system from breaking the whole process
        $options->set('silent', true);

        if (current_user_can('administrator')) {
            // we have an administrator, display the error as system message
            $options->set('admin', true);
        }
    }
}, 10, 4);

Changelog

Version Description
1.3 Introduced.
Last Update: 2023-12-20
Helpful?
See Also:

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.