framework/mail/BaseMailer.php
public function beforeSend($message)
    {
        $event = new MailEvent(['message' => $message]);
        $this->trigger(self::EVENT_BEFORE_SEND, $event);

        return $event->isValid;
    }
public function beforeSend($message)
    {
        $event = new MailEvent(['message' => $message]);
        $this->trigger(self::EVENT_BEFORE_SEND, $event);

        return $event->isValid;
    }
This method is invoked right before mail send.
You may override this method to do last-minute preparation for the message.
If you override this method, please make sure you call the parent implementation first.
@param MessageInterface $message
@return bool whether to continue sending an email.