本文整理匯總了PHP中phpmailer::AddCc方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpmailer::AddCc方法的具體用法?PHP phpmailer::AddCc怎麽用?PHP phpmailer::AddCc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpmailer
的用法示例。
在下文中一共展示了phpmailer::AddCc方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
/**
* Send mail, similar to PHP's mail
*
* A true return value does not automatically mean that the user received the
* email successfully. It just only means that the method used was able to
* process the request without any errors.
*
* The default content type is 'text/plain' which does not allow using HTML.
*/
public static function send($from_email, $from_name, array $to, $subject, $message, array $cc = array(), array $bcc = array(), array $attachments = array())
{
$mailer = new phpmailer();
$content_type = 'text/plain';
$mailer->ContentType = $content_type;
$mailer->Hostname = \lib\conf\constants::$domain;
$mailer->IsMail();
$mailer->IsHTML(false);
$mailer->From = $from_email;
$mailer->FromName = $from_name;
// add recipients
foreach ((array) $to as $recipient_name => $recipient_email) {
$mailer->AddAddress(trim($recipient_email), trim($recipient_name));
}
// Add any CC and BCC recipients
foreach ($cc as $recipient_name => $recipient_email) {
$mailer->AddCc(trim($recipient_email), trim($recipient_name));
}
foreach ($bcc as $recipient_name => $recipient_email) {
$mailer->AddBcc(trim($recipient_email), trim($recipient_name));
}
// Set mail's subject and body
$mailer->Subject = $subject;
$mailer->Body = $message;
foreach ($attachments as $attachment) {
$mailer->AddAttachment($attachment);
}
// Send!
$result = $mailer->Send();
return $result;
}