/** * Send an email * * @return boolean Email sent successfully */ public function sendMail() { $this->init(); if ($this->emailer->error) { return $this->fatalError($this->emailer->error_msg, $this->emailer->error_help); } /* Add attachments if any */ if (count($this->_attachments)) { foreach ($this->_attachments as $a) { $this->emailer->addAttachment($a[0], $a[1], $a[2]); } } $this->settings['board_name'] = $this->cleanMessage($this->settings['board_name']); $this->emailer->setFrom($this->from ? $this->from : $this->settings['email_out'], $this->settings['board_name']); $this->emailer->setTo($this->to); foreach ($this->cc as $cc) { $this->emailer->addCC($cc); } foreach ($this->bcc as $bcc) { $this->emailer->addBCC($bcc); } if (count($this->temp_headers)) { foreach ($this->temp_headers as $k => $v) { $this->emailer->setHeader($k, $v); } } //----------------------------------------- // Added strip_tags for the subject 4.16.2010 // so we can have links in subject for inline // notifications and still use the subject //----------------------------------------- $this->emailer->setSubject($this->_cleanSubject($this->subject)); /* If we're sending a HTML email, we need to manually send the plain text and HTML versions */ if ($this->html_email and $this->htmlTemplate) { /* Dynamically replace subject in template */ $this->htmlTemplate = str_ireplace(array('<#subject#>'), IPSText::utf8ToEntities($this->_cleanSubject($this->subject)), $this->htmlTemplate); $this->emailer->setPlainTextContent($this->plainTextTemplate); $this->emailer->setHtmlContent($this->htmlTemplate); } else { if ($this->message && !$this->plainTextTemplate) { /* Older methods pass message directly */ $this->emailer->setBody($this->message); } else { $this->emailer->setBody($this->plainTextTemplate); } } $this->emailer->sendMail(); /* Clear out stuffs */ $this->clearContent(); // Unset HTML setting to remain backwards compatibility //$this->html_email = FALSE; if ($this->emailer->error) { return $this->fatalError($this->emailer->error_msg, $this->emailer->error_help); } return true; }
/** * @param object $mail * @param array $receivers */ protected function sendEmail($mail, array $receivers) { $config = KunenaFactory::getConfig(); $email_recipient_count = !empty($config->email_recipient_count) ? $config->email_recipient_count : 1; $email_recipient_privacy = !empty($config->email_recipient_privacy) ? $config->email_recipient_privacy : 'bcc'; // If we hide email addresses from other users, we need to add TO address to prevent email from becoming spam if ($email_recipient_count > 1 && $email_recipient_privacy == 'bcc' && !empty($config->email_visible_address) && JMailHelper::isEmailAddress ( $config->email_visible_address )) { $mail->AddAddress($config->email_visible_address, JMailHelper::cleanAddress ( $config->board_title )); // Also make sure that email receiver limits are not violated (TO + CC + BCC = limit) if ($email_recipient_count > 9) $email_recipient_count--; } $chunks = array_chunk($receivers, $email_recipient_count); foreach ($chunks as $emails) { if ($email_recipient_count == 1 || $email_recipient_privacy == 'to') { $mail->ClearAddresses(); $mail->addRecipient($emails); } elseif ($email_recipient_privacy == 'cc') { $mail->ClearCCs(); $mail->addCC($emails); } else { $mail->ClearBCCs(); $mail->addBCC($emails); } $mail->Send(); } }