src/net/mail/Mailer.php
protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) {
        if (!empty($this->options['send-later'])) {
            $callable = [$this, 'sendMail'];
            register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers);

            $this->options['send-later'] = false;
            return true;
        }
        return false;

        // TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection
        //       and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is
        //       never full from just a redirect header PHP is waiting for the shutdown function to finish as it might
        //       push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown?
    }
protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) {
        if (!empty($this->options['send-later'])) {
            $callable = [$this, 'sendMail'];
            register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers);

            $this->options['send-later'] = false;
            return true;
        }
        return false;

        // TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection
        //       and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is
        //       never full from just a redirect header PHP is waiting for the shutdown function to finish as it might
        //       push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown?
    }
protected function sendLater ( $ sender , $ receiver , $ subject , $ message , array $ headers = [ ] ) { if ( ! empty ( $ this -> options [ 'send-later' ] ) ) { $ callable = [ $ this , 'sendMail' ] ; register_shutdown_function ( $ callable , $ sender , $ receiver , $ subject , $ message , $ headers ) ; $ this -> options [ 'send-later' ] = false ; return true ; } return false ; // TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection //       and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is //       never full from just a redirect header PHP is waiting for the shutdown function to finish as it might //       push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown? }
Delay sending of the mail to the script shutdown phase. Can be used to not to block other more important tasks.

NOTE: Usage of this method is a poor man's approach and a last resort. A more professional way to decouple sending
of mail is using a regular message queue.

@param  string   $sender             - mail sender
@param  string   $receiver           - mail receiver
@param  string   $subject            - mail subject
@param  string   $message            - mail body
@param  string[] $headers [optional] - additional MIME headers (default: none)

@return bool - whether sending of the email was successfully delayed
Delay sending of the mail to the script shutdown phase . Can be used to not to block other more important tasks .