src/Services/BaseService.php
public function sendEmail($data, $textView = null, $htmlView = null)
    {
        Session::replaceLookups($textView);
        Session::replaceLookups($htmlView);

        $view = [
            'html' => $htmlView,
            'text' => $textView
        ];

        /** @noinspection PhpVoidFunctionResultUsedInspection */
        $count = $this->mailer->send(
            $view,
            $data,
            function (Message $m) use ($data) {
                $to = array_get($data, 'to');
                $cc = array_get($data, 'cc');
                $bcc = array_get($data, 'bcc');
                $subject = array_get($data, 'subject');
                $fromName = array_get($data, 'from_name');
                $fromEmail = array_get($data, 'from_email');
                $replyName = array_get($data, 'reply_to_name');
                $replyEmail = array_get($data, 'reply_to_email');
                // Look for any attachment in request data.
                $attachment = $this->getAttachments();
                // No attachment in request data. Attachment found in email template.
                if (empty($attachment) && isset($data['attachment'])) {
                    // Get the attachment data from email template.
                    $attachment = $this->getAttachments($data['attachment']);
                }

                if (empty($fromEmail)) {
                    $fromEmail = config('mail.from.address');
                    $data['from_email'] = $fromEmail;
                    if (empty($fromName)) {
                        $fromName = config('mail.from.name');
                        $data['from_name'] = $fromName;
                    }
                }

                $to = static::sanitizeAndValidateEmails($to, 'swift');
                if (!empty($cc)) {
                    $cc = static::sanitizeAndValidateEmails($cc, 'swift');
                }
                if (!empty($bcc)) {
                    $bcc = static::sanitizeAndValidateEmails($bcc, 'swift');
                }

                $fromEmail = static::sanitizeAndValidateEmails($fromEmail, 'swift');
                if (!empty($replyEmail)) {
                    $replyEmail = static::sanitizeAndValidateEmails($replyEmail, 'swift');
                }

                $m->to($to);

                if (!empty($fromEmail)) {
                    $m->from($fromEmail, $fromName);
                }
                if (!empty($replyEmail)) {
                    $m->replyTo($replyEmail, $replyName);
                }

                if (!empty($subject)) {
                    Session::replaceLookups($subject);
                    $m->subject(static::applyDataToView($subject, $data));
                }

                if (!empty($attachment)) {
                    if (!is_array($attachment)) {
                        $attachment = [$attachment];
                    }
                    foreach ($attachment as $att) {
                        if ($att instanceof Attachment) {
                            $m->attachData($att->getContent(), $att->getName());
                            $att->unlink();
                        }
                    }
                }

                if (!empty($bcc)) {
                    $m->bcc($bcc);
                }
                if (!empty($cc)) {
                    $m->cc($cc);
                }
            }
        );

        return $count;
    }
public function sendEmail($data, $textView = null, $htmlView = null)
    {
        Session::replaceLookups($textView);
        Session::replaceLookups($htmlView);

        $view = [
            'html' => $htmlView,
            'text' => $textView
        ];

        /** @noinspection PhpVoidFunctionResultUsedInspection */
        $count = $this->mailer->send(
            $view,
            $data,
            function (Message $m) use ($data) {
                $to = array_get($data, 'to');
                $cc = array_get($data, 'cc');
                $bcc = array_get($data, 'bcc');
                $subject = array_get($data, 'subject');
                $fromName = array_get($data, 'from_name');
                $fromEmail = array_get($data, 'from_email');
                $replyName = array_get($data, 'reply_to_name');
                $replyEmail = array_get($data, 'reply_to_email');
                // Look for any attachment in request data.
                $attachment = $this->getAttachments();
                // No attachment in request data. Attachment found in email template.
                if (empty($attachment) && isset($data['attachment'])) {
                    // Get the attachment data from email template.
                    $attachment = $this->getAttachments($data['attachment']);
                }

                if (empty($fromEmail)) {
                    $fromEmail = config('mail.from.address');
                    $data['from_email'] = $fromEmail;
                    if (empty($fromName)) {
                        $fromName = config('mail.from.name');
                        $data['from_name'] = $fromName;
                    }
                }

                $to = static::sanitizeAndValidateEmails($to, 'swift');
                if (!empty($cc)) {
                    $cc = static::sanitizeAndValidateEmails($cc, 'swift');
                }
                if (!empty($bcc)) {
                    $bcc = static::sanitizeAndValidateEmails($bcc, 'swift');
                }

                $fromEmail = static::sanitizeAndValidateEmails($fromEmail, 'swift');
                if (!empty($replyEmail)) {
                    $replyEmail = static::sanitizeAndValidateEmails($replyEmail, 'swift');
                }

                $m->to($to);

                if (!empty($fromEmail)) {
                    $m->from($fromEmail, $fromName);
                }
                if (!empty($replyEmail)) {
                    $m->replyTo($replyEmail, $replyName);
                }

                if (!empty($subject)) {
                    Session::replaceLookups($subject);
                    $m->subject(static::applyDataToView($subject, $data));
                }

                if (!empty($attachment)) {
                    if (!is_array($attachment)) {
                        $attachment = [$attachment];
                    }
                    foreach ($attachment as $att) {
                        if ($att instanceof Attachment) {
                            $m->attachData($att->getContent(), $att->getName());
                            $att->unlink();
                        }
                    }
                }

                if (!empty($bcc)) {
                    $m->bcc($bcc);
                }
                if (!empty($cc)) {
                    $m->cc($cc);
                }
            }
        );

        return $count;
    }
Sends out emails.

@param array $data
@param null  $textView
@param null  $htmlView

@return mixed