public function sendEmail($TOs = null, $CCs = null, $BCCs = null, $subject, $body, $attachments = null, $isHTML = false)
    {
        $mail = $this->_mail;
        // add TO addresses
        if ($TOs) {
            foreach ($TOs as $to) {
                if (is_array($to)) {
                    $mail->addTo($to['email'], $to['name']);
                } else {
                    $mail->addTo($to);
                }
            }
        }
        // add CC addresses
        if ($CCs) {
            foreach ($CCs as $cc) {
                if (is_array($cc)) {
                    $mail->AddCC($cc['email'], $cc['name']);
                } else {
                    $mail->AddCC($cc);
                }
            }
        }
        // add BCC addresses
        if ($BCCs) {
            foreach ($BCCs as $bcc) {
                if (is_array($bcc)) {
                    $mail->AddBCC($bcc['email'], $bcc['name']);
                } else {
                    $mail->AddBCC($bcc);
                }
            }
        }
        // add attachments
        if ($attachments)
            foreach ($attachments as $att)
                $mail->CreateAttachment(file_get_contents($att));
        $mail->setSubject($subject);
        $body = str_replace("\\n", "\n", $body);
        if ($isHTML == TRUE) {
            $mail->setBodyHTML($body);
        } else {
            $mail->setBodyText($body);
        }

        try {
            $result = $mail->Send(); //Will throw an exception if sending fails
            $this->logEmail('Success', $subject, $body, $TOs, $CCs, $BCCs);
            return TRUE;
        } catch (Exception $e) {
            $result = "ERROR: " . $e->getMessage();
            $this->logEmail($result, $subject, $body, $TOs, $CCs, $BCCs);
            return FALSE;
        }
    }
public function sendEmail($TOs = null, $CCs = null, $BCCs = null, $subject, $body, $attachments = null, $isHTML = false)
    {
        $mail = $this->_mail;
        // add TO addresses
        if ($TOs) {
            foreach ($TOs as $to) {
                if (is_array($to)) {
                    $mail->addTo($to['email'], $to['name']);
                } else {
                    $mail->addTo($to);
                }
            }
        }
        // add CC addresses
        if ($CCs) {
            foreach ($CCs as $cc) {
                if (is_array($cc)) {
                    $mail->AddCC($cc['email'], $cc['name']);
                } else {
                    $mail->AddCC($cc);
                }
            }
        }
        // add BCC addresses
        if ($BCCs) {
            foreach ($BCCs as $bcc) {
                if (is_array($bcc)) {
                    $mail->AddBCC($bcc['email'], $bcc['name']);
                } else {
                    $mail->AddBCC($bcc);
                }
            }
        }
        // add attachments
        if ($attachments)
            foreach ($attachments as $att)
                $mail->CreateAttachment(file_get_contents($att));
        $mail->setSubject($subject);
        $body = str_replace("\\n", "\n", $body);
        if ($isHTML == TRUE) {
            $mail->setBodyHTML($body);
        } else {
            $mail->setBodyText($body);
        }

        try {
            $result = $mail->Send(); //Will throw an exception if sending fails
            $this->logEmail('Success', $subject, $body, $TOs, $CCs, $BCCs);
            return TRUE;
        } catch (Exception $e) {
            $result = "ERROR: " . $e->getMessage();
            $this->logEmail($result, $subject, $body, $TOs, $CCs, $BCCs);
            return FALSE;
        }
    }
public function sendEmail ( $ TOs = null , $ CCs = null , $ BCCs = null , $ subject , $ body , $ attachments = null , $ isHTML = false ) { $ mail = $ this -> _mail ; // add TO addresses if ( $ TOs ) { foreach ( $ TOs as $ to ) { if ( is_array ( $ to ) ) { $ mail -> addTo ( $ to [ 'email' ] , $ to [ 'name' ] ) ; } else { $ mail -> addTo ( $ to ) ; } } } // add CC addresses if ( $ CCs ) { foreach ( $ CCs as $ cc ) { if ( is_array ( $ cc ) ) { $ mail -> AddCC ( $ cc [ 'email' ] , $ cc [ 'name' ] ) ; } else { $ mail -> AddCC ( $ cc ) ; } } } // add BCC addresses if ( $ BCCs ) { foreach ( $ BCCs as $ bcc ) { if ( is_array ( $ bcc ) ) { $ mail -> AddBCC ( $ bcc [ 'email' ] , $ bcc [ 'name' ] ) ; } else { $ mail -> AddBCC ( $ bcc ) ; } } } // add attachments if ( $ attachments ) foreach ( $ attachments as $ att ) $ mail -> CreateAttachment ( file_get_contents ( $ att ) ) ; $ mail -> setSubject ( $ subject ) ; $ body = str_replace ( "\\n" , "\n" , $ body ) ; if ( $ isHTML == TRUE ) { $ mail -> setBodyHTML ( $ body ) ; } else { $ mail -> setBodyText ( $ body ) ; } try { $ result = $ mail -> Send ( ) ; //Will throw an exception if sending fails $ this -> logEmail ( 'Success' , $ subject , $ body , $ TOs , $ CCs , $ BCCs ) ; return TRUE ; } catch ( Exception $ e ) { $ result = "ERROR: " . $ e -> getMessage ( ) ; $ this -> logEmail ( $ result , $ subject , $ body , $ TOs , $ CCs , $ BCCs ) ; return FALSE ; } }
A convenience function that will issue an email based on the parameter provided
Will log email attempts but will NOT run the body through a template

@param array $TOs
@param array $CCs
@param array $BCCs
@param array $subject
@param array $body
@param array $attachments
@param boolean $isHTML
@return boolean $result - TRUE on success, FALSE on failure
A convenience function that will issue an email based on the parameter provided Will log email attempts but will NOT run the body through a template