public function send()
    {
        $this->logger->debug(
            'Attempting to send an email',
            $this->to()
        );

        $mail = $this->phpMailer;

        try {
            $this->setSmtpOptions($mail);

            $mail->CharSet = 'UTF-8';

            // Setting reply-to field, if required.
            $replyTo = $this->replyTo();
            if ($replyTo) {
                $replyArr = $this->emailToArray($replyTo);
                $mail->addReplyTo($replyArr['email'], $replyArr['name']);
            }

            // Setting from (sender) field.
            $from = $this->from();
            $fromArr = $this->emailToArray($from);
            $mail->setFrom($fromArr['email'], $fromArr['name']);

            // Setting to (recipients) field(s).
            $to = $this->to();
            foreach ($to as $recipient) {
                $toArr = $this->emailToArray($recipient);
                $mail->addAddress($toArr['email'], $toArr['name']);
            }

            // Setting cc (carbon-copy) field(s).
            $cc = $this->cc();
            foreach ($cc as $ccRecipient) {
                $ccArr = $this->emailToArray($ccRecipient);
                $mail->addCC($ccArr['email'], $ccArr['name']);
            }

            // Setting bcc (black-carbon-copy) field(s).
            $bcc = $this->bcc();
            foreach ($bcc as $bccRecipient) {
                $bccArr = $this->emailToArray($bccRecipient);
                $mail->addBCC($bccArr['email'], $bccArr['name']);
            }

            // Setting attachment(s), if required.
            $attachments = $this->attachments();
            foreach ($attachments as $att) {
                $mail->addAttachment($att);
            }

            $mail->isHTML(true);

            $mail->Subject = $this->subject();
            $mail->Body    = $this->msgHtml();
            $mail->AltBody = $this->msgTxt();

            $ret = $mail->send();

            $this->logSend($ret, $mail);

            return $ret;
        } catch (Exception $e) {
            $this->logger->error(
                sprintf('Error sending email: %s', $e->getMessage())
            );
        }
    }
public function send()
    {
        $this->logger->debug(
            'Attempting to send an email',
            $this->to()
        );

        $mail = $this->phpMailer;

        try {
            $this->setSmtpOptions($mail);

            $mail->CharSet = 'UTF-8';

            // Setting reply-to field, if required.
            $replyTo = $this->replyTo();
            if ($replyTo) {
                $replyArr = $this->emailToArray($replyTo);
                $mail->addReplyTo($replyArr['email'], $replyArr['name']);
            }

            // Setting from (sender) field.
            $from = $this->from();
            $fromArr = $this->emailToArray($from);
            $mail->setFrom($fromArr['email'], $fromArr['name']);

            // Setting to (recipients) field(s).
            $to = $this->to();
            foreach ($to as $recipient) {
                $toArr = $this->emailToArray($recipient);
                $mail->addAddress($toArr['email'], $toArr['name']);
            }

            // Setting cc (carbon-copy) field(s).
            $cc = $this->cc();
            foreach ($cc as $ccRecipient) {
                $ccArr = $this->emailToArray($ccRecipient);
                $mail->addCC($ccArr['email'], $ccArr['name']);
            }

            // Setting bcc (black-carbon-copy) field(s).
            $bcc = $this->bcc();
            foreach ($bcc as $bccRecipient) {
                $bccArr = $this->emailToArray($bccRecipient);
                $mail->addBCC($bccArr['email'], $bccArr['name']);
            }

            // Setting attachment(s), if required.
            $attachments = $this->attachments();
            foreach ($attachments as $att) {
                $mail->addAttachment($att);
            }

            $mail->isHTML(true);

            $mail->Subject = $this->subject();
            $mail->Body    = $this->msgHtml();
            $mail->AltBody = $this->msgTxt();

            $ret = $mail->send();

            $this->logSend($ret, $mail);

            return $ret;
        } catch (Exception $e) {
            $this->logger->error(
                sprintf('Error sending email: %s', $e->getMessage())
            );
        }
    }
public function send ( ) { $ this -> logger -> debug ( 'Attempting to send an email' , $ this -> to ( ) ) ; $ mail = $ this -> phpMailer ; try { $ this -> setSmtpOptions ( $ mail ) ; $ mail -> CharSet = 'UTF-8' ; // Setting reply-to field, if required. $ replyTo = $ this -> replyTo ( ) ; if ( $ replyTo ) { $ replyArr = $ this -> emailToArray ( $ replyTo ) ; $ mail -> addReplyTo ( $ replyArr [ 'email' ] , $ replyArr [ 'name' ] ) ; } // Setting from (sender) field. $ from = $ this -> from ( ) ; $ fromArr = $ this -> emailToArray ( $ from ) ; $ mail -> setFrom ( $ fromArr [ 'email' ] , $ fromArr [ 'name' ] ) ; // Setting to (recipients) field(s). $ to = $ this -> to ( ) ; foreach ( $ to as $ recipient ) { $ toArr = $ this -> emailToArray ( $ recipient ) ; $ mail -> addAddress ( $ toArr [ 'email' ] , $ toArr [ 'name' ] ) ; } // Setting cc (carbon-copy) field(s). $ cc = $ this -> cc ( ) ; foreach ( $ cc as $ ccRecipient ) { $ ccArr = $ this -> emailToArray ( $ ccRecipient ) ; $ mail -> addCC ( $ ccArr [ 'email' ] , $ ccArr [ 'name' ] ) ; } // Setting bcc (black-carbon-copy) field(s). $ bcc = $ this -> bcc ( ) ; foreach ( $ bcc as $ bccRecipient ) { $ bccArr = $ this -> emailToArray ( $ bccRecipient ) ; $ mail -> addBCC ( $ bccArr [ 'email' ] , $ bccArr [ 'name' ] ) ; } // Setting attachment(s), if required. $ attachments = $ this -> attachments ( ) ; foreach ( $ attachments as $ att ) { $ mail -> addAttachment ( $ att ) ; } $ mail -> isHTML ( true ) ; $ mail -> Subject = $ this -> subject ( ) ; $ mail -> Body = $ this -> msgHtml ( ) ; $ mail -> AltBody = $ this -> msgTxt ( ) ; $ ret = $ mail -> send ( ) ; $ this -> logSend ( $ ret , $ mail ) ; return $ ret ; } catch ( Exception $ e ) { $ this -> logger -> error ( sprintf ( 'Error sending email: %s' , $ e -> getMessage ( ) ) ) ; } }
Send the email to all recipients

@return boolean Success / Failure.
@todo Implement methods and property for toggling rich-text vs. plain-text
emails (`$mail->isHTML(true)`).
Send the email to all recipients