本文整理匯總了PHP中JMail::addCC方法的典型用法代碼示例。如果您正苦於以下問題:PHP JMail::addCC方法的具體用法?PHP JMail::addCC怎麽用?PHP JMail::addCC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JMail
的用法示例。
在下文中一共展示了JMail::addCC方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAddCC
/**
* Tests the addCC method.
*
* @covers JMail::addCC
*
* @return void
*/
public function testAddCC()
{
$recipient = 'test@example.com';
$name = 'test_name';
$expected = array(array('test@example.com', 'test_name'));
$this->object->addCC($recipient, $name);
$this->assertThat($expected, $this->equalTo(TestReflection::getValue($this->object, 'cc')));
}
示例2: send
/**
* @param JMail $mail
* @param array $receivers
*
* @return boolean
*/
public static function send(JMail $mail, array $receivers)
{
$config = KunenaFactory::getConfig();
if (!empty($config->email_recipient_count)) {
$email_recipient_count = $config->email_recipient_count;
} else {
$email_recipient_count = 1;
}
$email_recipient_privacy = $config->get('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' && JMailHelper::isEmailAddress($config->get('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);
$success = true;
foreach ($chunks as $emails) {
if ($email_recipient_count == 1 || $email_recipient_privacy == 'to') {
echo 'TO ';
$mail->ClearAddresses();
$mail->addRecipient($emails);
} elseif ($email_recipient_privacy == 'cc') {
echo 'CC ';
$mail->ClearCCs();
$mail->addCC($emails);
} else {
echo 'BCC ';
$mail->ClearBCCs();
$mail->addBCC($emails);
}
try {
$mail->Send();
} catch (Exception $e) {
$success = false;
JLog::add($e->getMessage(), JLog::ERROR, 'kunena');
}
}
return $success;
}
示例3: sendEmail
public static function sendEmail($from, $fromName, $replyTo, $toEmail, $cc, $bcc, $subject, $content, $isHtml)
{
jimport('joomla.mail.mail');
$mail = new JMail();
$mail->setSender(array($from, $fromName));
if (isset($replyTo)) {
$mail->addReplyTo($replyTo);
}
$mail->addRecipient($toEmail);
if (isset($cc)) {
$mail->addCC($cc);
}
if (isset($bcc)) {
$mail->addBCC($bcc);
}
$mail->setSubject($subject);
$mail->setBody($content);
$mail->IsHTML($isHtml);
$ret = $mail->send();
$log = Logger::getInstance();
$log->LogDebug("E-mail with subject " . $subject . " sent from " . $from . " to " . $toEmail . " " . serialize($bcc) . " result:" . $ret);
return $ret;
}