本文整理汇总了PHP中PHPMailer::AddCC方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::AddCC方法的具体用法?PHP PHPMailer::AddCC怎么用?PHP PHPMailer::AddCC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::AddCC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Cc
/**
* Adds to the "Cc" recipient collection.
*
* @param mixed $RecipientEmail An email (or array of emails) to add to the "Cc" recipient collection.
* @param string $RecipientName The recipient name associated with $RecipientEmail. If $RecipientEmail is
* an array of email addresses, this value will be ignored.
* @return Email
*/
public function Cc($RecipientEmail, $RecipientName = '')
{
ob_start();
$this->PhpMailer->AddCC($RecipientEmail, $RecipientName);
ob_end_clean();
return $this;
}
示例2: Send
function Send()
{
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->Host = $this->smtp['smtp_server'];
$mail->Port = $this->smtp['smtp_port'];
if ($this->smtp['smtp_enable']) {
$mail->IsSMTP();
$mail->Username = $this->smtp['smtp_usr'];
$mail->Password = $this->smtp['smtp_psw'];
$mail->SMTPAuth = $this->smtp['smtp_auth'] ? true : false;
}
if ($this->smtp['smtp_from_email']) {
$mail->SetFrom($this->smtp['smtp_from_email'], $this->smtp['smtp_from_name']);
} else {
$mail->SetFrom($this->smtp['smtp_server'], $this->smtp['smtp_usr']);
}
if (is_array($this->to)) {
foreach ($this->to as $key => $val) {
$name = is_numeric($key) ? "" : $key;
$mail->AddAddress($val, $name);
}
} else {
$mail->AddAddress($this->to, $this->to_name);
}
if (!empty($this->smtp['smtp_reply_email'])) {
$mail->AddReplyTo($this->smtp['smtp_reply_email'], $this->smtp['smtp_reply_name']);
}
if ($this->cc) {
if (is_array($this->cc)) {
foreach ($this->cc as $keyc => $valcc) {
$name = is_numeric($keyc) ? "" : $keyc;
$mail->AddCC($valcc, $name);
}
} else {
$mail->AddCC($this->cc, $this->cc_name);
}
}
if ($this->attach) {
if (is_array($this->attach)) {
foreach ($this->attach as $key => $val) {
$mail->AddAttachment($val);
}
} else {
$mail->AddAttachment($this->attach);
}
}
// $mail->SMTPSecure = 'ssl';
$mail->SMTPSecure = "tls";
$mail->WordWrap = 50;
$mail->IsHTML($this->is_html);
$mail->Subject = $this->subject;
$mail->Body = $this->body;
$mail->AltBody = "";
// return $mail->Body;
return $mail->Send();
}
示例3: setIndex
/**
* @brief Function setIndex
* envia o email do usuario na index do site
* @param void
* @return mensagem indicador de erro ou sucesso
*/
public function setIndex()
{
if (@$_POST) {
$this->name = Dbcommand::post('name');
$this->mail_job = Dbcommand::post('mail');
$this->phone = Dbcommand::post('phone');
$this->title = Dbcommand::post('title');
$this->message = Dbcommand::post('message');
if (empty($this->name) || empty($this->mail_job) || empty($this->message) || empty($this->title)) {
echo "<script> window.alert('Campo vazio!!') </script>\n\t <script> window.location = 'index.php'; </script>";
die;
}
if (!ValidationData::name($this->name) || !ValidationData::mail($this->mail_job) || !ValidationData::text($this->message) || !ValidationData::text($this->title)) {
echo "<script> window.alert('Campo em formato inválido!!') </script>\n \t<script> window.location = 'index.php'; </script>";
die;
} else {
$mail = new PHPMailer();
// Classe para enviar emails
$mail->IsSMTP();
// Define que a mensagem sera SMTP
// Define o remetente
$mail->From = $this->from;
// Seu e-mail
$mail->Sender = $this->from;
// Seu e-mail
$mail->FromName = $this->fromName;
// Seu nome
// Define os destinatario(s)
$mail->AddAddress($this->from, $this->name);
// Sera pra propria
$mail->AddCC($this->mail_job, "Cópia | " . $this->fromName);
// Copia pro Usuario
$mail->IsHTML(true);
// Define que o e-mail sera enviado como HTML
$mail->CharSet = 'utf-8';
// Charset da mensagem
// Define a mensagem (Texto e Assunto)
$mail->Subject = $this->title;
$mail->Body = $this->message;
$mail->AltBody = trim(strip_tags($this->message));
// A mesma mensagem em texto puro
$sended = $mail->Send();
// Envia o e-mail
$mail->ClearAllRecipients();
// Limpa os destinatarios e os anexos
$this->name = Criptography::BASE64($this->name, 1);
$this->mail_job = Criptography::BASE64($this->mail_job, 1);
$this->phone = Criptography::BASE64($this->phone, 1);
$this->title = Criptography::BASE64($this->title, 1);
$this->message = Criptography::BASE64($this->message, 1);
$this->date_in = Criptography::BASE64(date("Y-m-d H:i:s"), 1);
Dbcommand::insert('tb_emails', array('EM_NOME', 'EM_EMAIL', 'EM_ASSUNTO', 'EM_MENSAGEM', 'EM_DATA', 'EM_TEL', 'EM_STATUS'), array($this->name, $this->mail_job, $this->title, $this->message, $this->date_in, $this->phone, $this->status));
if ($sended) {
echo "<script> window.alert('Mensagem enviada com Sucesso') </script>\n \t <script> window.location = 'index.php'; </script>";
} else {
echo "<script> window.alert('Nao foi possível enviar o e-mail,\n mas ele podera ser visto pelo Administrador do Site.') </script>\n <script> window.location = 'index.php'; </script>";
}
}
}
}
示例4: addAddress
/**
*
* Can be used to add various types of address
*
* @param string $type
* @param $address
* @param string $name
* @throws \InvalidArgumentException
* @return $this
* @author Tim Perry
*/
public function addAddress($type, $address, $name = '')
{
if (empty($address) || filter_var($address, FILTER_VALIDATE_EMAIL) === false) {
$message = "Invalid address please provide a valid email address";
throw new \InvalidArgumentException($message);
}
switch ($type) {
default:
case 'to':
$this->mailer->AddAddress($address, $name);
break;
case 'from':
$this->mailer->SetFrom($address, $name);
break;
case 'bcc':
$this->mailer->AddBCC($address, $name);
break;
case 'cc':
$this->mailer->AddCC($address, $name);
break;
case 'replyto':
$this->mailer->AddReplyTo($address, $name);
break;
}
return $this;
}
示例5: send
/**
* send an email
*
* @param string $toaddress
* @param string $toname
* @param string $subject
* @param string $mailtext
* @param string $fromaddress
* @param string $fromname
* @param bool $html
*/
public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '')
{
$SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail');
$SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1');
$SMTPAUTH = OC_Config::getValue('mail_smtpauth', false);
$SMTPUSERNAME = OC_Config::getValue('mail_smtpname', '');
$SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', '');
$mailo = new PHPMailer(true);
if ($SMTPMODE == 'sendmail') {
$mailo->IsSendmail();
} elseif ($SMTPMODE == 'smtp') {
$mailo->IsSMTP();
} elseif ($SMTPMODE == 'qmail') {
$mailo->IsQmail();
} else {
$mailo->IsMail();
}
$mailo->Host = $SMTPHOST;
$mailo->SMTPAuth = $SMTPAUTH;
$mailo->Username = $SMTPUSERNAME;
$mailo->Password = $SMTPPASSWORD;
$mailo->From = $fromaddress;
$mailo->FromName = $fromname;
$mailo->Sender = $fromaddress;
$a = explode(' ', $toaddress);
try {
foreach ($a as $ad) {
$mailo->AddAddress($ad, $toname);
}
if ($ccaddress != '') {
$mailo->AddCC($ccaddress, $ccname);
}
if ($bcc != '') {
$mailo->AddBCC($bcc);
}
$mailo->AddReplyTo($fromaddress, $fromname);
$mailo->WordWrap = 50;
if ($html == 1) {
$mailo->IsHTML(true);
} else {
$mailo->IsHTML(false);
}
$mailo->Subject = $subject;
if ($altbody == '') {
$mailo->Body = $mailtext . OC_MAIL::getfooter();
$mailo->AltBody = '';
} else {
$mailo->Body = $mailtext;
$mailo->AltBody = $altbody;
}
$mailo->CharSet = 'UTF-8';
$mailo->Send();
unset($mailo);
OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG);
} catch (Exception $exception) {
OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
throw $exception;
}
}
示例6: phpmail_send
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
$CI =& get_instance();
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsHtml();
if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
$mail->IsSMTP();
$mail->SMTPAuth = true;
if ($CI->mdl_mcb_data->setting('smtp_security')) {
$mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
}
$mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
$mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
$mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
$mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
} elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
$mail->IsSendmail();
}
if (is_array($from)) {
$mail->SetFrom($from[0], $from[1]);
} else {
$mail->SetFrom($from);
}
$mail->Subject = $subject;
$mail->Body = $message;
$to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
foreach ($to as $address) {
$mail->AddAddress($address);
}
if ($cc) {
$cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
foreach ($cc as $address) {
$mail->AddCC($address);
}
}
if ($bcc) {
$bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
foreach ($bcc as $address) {
$mail->AddBCC($address);
}
}
if ($attachment_path) {
$mail->AddAttachment($attachment_path);
}
if ($mail->Send()) {
if (isset($CI->load->_ci_classes['session'])) {
$CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
return TRUE;
}
} else {
if (isset($CI->this->load->_ci_classes['session'])) {
$CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
return FALSE;
}
}
}
示例7: sendemail
function sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message, $type = "plain", $cc = "", $bcc = "")
{
global $settings, $locale;
require_once INCLUDES . "class.phpmailer.php";
$mail = new PHPMailer();
if (file_exists(INCLUDES . "language/phpmailer.lang-" . $locale['phpmailer'] . ".php")) {
$mail->SetLanguage($locale['phpmailer'], INCLUDES . "language/");
} else {
$mail->SetLanguage("en", INCLUDES . "language/");
}
if (!$settings['smtp_host']) {
$mail->IsMAIL();
} else {
$mail->IsSMTP();
$mail->Host = $settings['smtp_host'];
$mail->Port = $settings['smtp_port'];
$mail->SMTPAuth = $settings['smtp_auth'] ? true : false;
$mail->Username = $settings['smtp_username'];
$mail->Password = $settings['smtp_password'];
}
$mail->CharSet = $locale['charset'];
$mail->From = $fromemail;
$mail->FromName = $fromname;
$mail->AddAddress($toemail, $toname);
$mail->AddReplyTo($fromemail, $fromname);
if ($cc) {
$cc = explode(", ", $cc);
foreach ($cc as $ccaddress) {
$mail->AddCC($ccaddress);
}
}
if ($bcc) {
$bcc = explode(", ", $bcc);
foreach ($bcc as $bccaddress) {
$mail->AddBCC($bccaddress);
}
}
if ($type == "plain") {
$mail->IsHTML(false);
} else {
$mail->IsHTML(true);
}
$mail->Subject = $subject;
$mail->Body = $message;
if (!$mail->Send()) {
$mail->ErrorInfo;
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
return false;
} else {
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
return true;
}
}
示例8: Send
public function Send(IEmailMessage $emailMessage)
{
$this->phpMailer->ClearAllRecipients();
$this->phpMailer->ClearReplyTos();
$this->phpMailer->CharSet = $emailMessage->Charset();
$this->phpMailer->Subject = $emailMessage->Subject();
$this->phpMailer->Body = $emailMessage->Body();
$from = $emailMessage->From();
$defaultFrom = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_ADDRESS);
$defaultName = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_NAME);
$address = empty($defaultFrom) ? $from->Address() : $defaultFrom;
$name = empty($defaultName) ? $from->Name() : $defaultName;
$this->phpMailer->SetFrom($address, $name);
$replyTo = $emailMessage->ReplyTo();
$this->phpMailer->AddReplyTo($replyTo->Address(), $replyTo->Name());
$to = $this->ensureArray($emailMessage->To());
$toAddresses = new StringBuilder();
foreach ($to as $address) {
$toAddresses->Append($address->Address());
$this->phpMailer->AddAddress($address->Address(), $address->Name());
}
$cc = $this->ensureArray($emailMessage->CC());
foreach ($cc as $address) {
$this->phpMailer->AddCC($address->Address(), $address->Name());
}
$bcc = $this->ensureArray($emailMessage->BCC());
foreach ($bcc as $address) {
$this->phpMailer->AddBCC($address->Address(), $address->Name());
}
if ($emailMessage->HasStringAttachment()) {
Log::Debug('Adding email attachment %s', $emailMessage->AttachmentFileName());
$this->phpMailer->AddStringAttachment($emailMessage->AttachmentContents(), $emailMessage->AttachmentFileName());
}
Log::Debug('Sending %s email to: %s from: %s', get_class($emailMessage), $toAddresses->ToString(), $from->Address());
$success = false;
try {
$success = $this->phpMailer->Send();
} catch (Exception $ex) {
Log::Error('Failed sending email. Exception: %s', $ex);
}
Log::Debug('Email send success: %d. %s', $success, $this->phpMailer->ErrorInfo);
}
示例9: send
/**
* 发送邮件
*
* @param string $to
* @param string $to_name
* @param string $subject
* @param string $body
* @param string $mailtype
* @return boolean
*/
public static function send($to, $to_name, $subject, $body, $chaosong = array(), $mailtype = 'txt')
{
self::init();
$send_type = mod_config::get_one_config('fl_sendemailtype') == '1' ? 'smtp' : 'mail';
$mail = new PHPMailer();
$mail->SMTPDebug = false;
// 发送方式
if ($send_type == 'smtp') {
self::smtp_init();
$mail->IsSMTP();
$mail->Host = self::$smtp_server;
$mail->Port = self::$smtp_port;
$mail->SmtpSsl = self::$smtp_ssl;
// SSL 连接
if (self::$smtp_auth) {
$mail->SMTPAuth = true;
$mail->Username = self::$smtp_user;
$mail->Password = self::$smtp_pwd;
} else {
$mail->SMTPAuth = false;
}
} elseif ($send_type == 'mail') {
$mail->IsMail();
}
// 发件人邮箱
$mail->From = self::$from_email;
// 发件人名称
if (self::$from_name != '') {
$mail->FromName = self::$from_name;
}
// 收件人邮箱和姓名
$mail->AddAddress($to, $to_name);
if ($chaosong) {
foreach ($chaosong as $v) {
$mail->AddCC($v['to'], $v['name']);
}
}
// 邮件编码
$mail->CharSet = self::$charset;
// 邮件编码方式
$mail->Encoding = "base64";
// 邮件格式类型
if ($mailtype == 'txt') {
$mail->IsHTML(false);
} elseif ($mailtype == 'html') {
$mail->IsHTML(true);
$mail->AltBody = "text/html";
}
$mail->Subject = $subject;
// 邮件主题
$mail->Body = $body;
// 邮件内容D
return !$mail->Send() ? false : true;
}
示例10: send
public function send($retry = 3)
{
$this->ci =& get_instance();
$configFile = 'email';
$this->ci->config->load($configFile, true);
$mail = new PHPMailer(true);
$mail->IsSMTP();
// set mailer to use SMTP
$mail->Host = $this->ci->config->item('smtp_host', $configFile);
$mail->Port = $this->ci->config->item('smtp_port', $configFile);
$mail->Username = $this->ci->config->item('smtp_user', $configFile);
$mail->Password = $this->ci->config->item('smtp_passwd', $configFile);
$mail->From = $this->ci->config->item('from', $configFile);
$mail->SMTPAuth = true;
$mail->CharSet = "utf-8";
if (!empty($this->_fromName)) {
$mail->FromName = $this->_fromName;
} else {
$mail->FromName = $this->ci->config->item('from_name', $configFile);
}
foreach ($this->_rcvAddrs as $rcver) {
$mail->AddAddress($rcver);
}
foreach ($this->_ccAddrs as $ccAddr) {
$mail->AddCC($ccAddr);
}
$mail->IsHTML(true);
// set email format to HTML
$mail->Subject = $this->_title;
if ($this->_bodyType == 'plain') {
$mail->Body = nl2br($this->_body);
} else {
if ($this->_bodyType == 'html') {
$mail->Body = $this->_body;
} else {
$mail->Body = $this->_body;
}
}
foreach ($this->_attachs as $attachFile) {
$mail->AddAttachment($attachFile, basename($attachFile));
}
while ($retry) {
try {
$mail->Send();
return true;
} catch (Exception $e) {
$retry--;
}
}
$logParams = array('message' => $e->getMessage(), 'receiver' => $this->_rcvAddrs, 'cc' => $this->_ccAddrs, 'title' => $this->_title, 'body' => $this->_body);
$ci =& get_instance();
$ci->log->log('warning', 'mail failed', $logParams);
return false;
}
示例11: convert_mail
private function convert_mail()
{
foreach ($this->mail_to_send->get_recipients() as $recipient => $name) {
$this->mailer->AddAddress($recipient, $name);
}
// cc
foreach ($this->mail_to_send->get_cc_recipients() as $recipient => $name) {
$this->mailer->AddCC($recipient, $name);
}
// bcc
foreach ($this->mail_to_send->get_bcc_recipients() as $recipient => $name) {
$this->mailer->AddBCC($recipient, $name);
}
// from
$this->mailer->SetFrom($this->mail_to_send->get_sender_mail(), $this->mail_to_send->get_sender_name());
$this->mailer->AddReplyTo($this->mail_to_send->get_reply_to_mail() ? $this->mail_to_send->get_reply_to_mail() : $this->mail_to_send->get_sender_mail(), $this->mail_to_send->get_reply_to_name() ? $this->mail_to_send->get_reply_to_name() : $this->mail_to_send->get_sender_name());
$this->mailer->Subject = $this->mail_to_send->get_subject();
// content
$this->convert_content();
}
示例12: init
public function init()
{
if ($this->finish()) {
$mail = $this->phpmailer();
$mail = new PHPMailer(true);
$mail->IsHTML(true);
try {
$mail->Body = $this->body();
$mail->Subject = $this->subject();
$mail->From = $this->from('email');
$mail->FromName = $this->from('name');
$mail->AddReplyTo($this->from('email'));
/** SMTP OPTIONS **/
if ($this->Config->smtp['use'] != 'no') {
$mail->IsSMTP();
$mail->Host = $this->Config->smtp['host'];
$mail->Port = $this->Config->smtp['port'];
$mail->SMTPSecure = $this->Config->smtp['secure'];
if ($this->Config->smtp['auth'] != 'no') {
$mail->SMTPAuth = true;
$mail->Username = $this->Config->smtp['username'];
$mail->Password = $this->Config->smtp['password'];
}
}
// Adds Addresses
foreach ($this->Config->Address as $Address) {
if (!empty($Address)) {
$mail->AddAddress($Address);
}
}
// Adds cc
foreach ($this->Config->Cc as $Address) {
if (!empty($Address)) {
$mail->AddCC($Address);
}
}
$mail->CharSet = $this->Config->charset;
$email = $mail->Send();
if ($email) {
if (IS_AJAX) {
echo json_encode(true);
} else {
echo $this->msg['success'];
}
}
} catch (Exception $e) {
if (IS_AJAX) {
echo json_encode(false);
} else {
echo $this->msg['error'];
}
}
}
}
示例13: SetAddress
/**
* Adds all of the addresses
* @access public
* @param string $sAddress
* @param string $sName
* @param string $sType
* @return boolean
*/
function SetAddress($sAddress, $sName = '', $sType = 'to')
{
switch ($sType) {
case 'to':
return $this->Mail->AddAddress($sAddress, $sName);
case 'cc':
return $this->Mail->AddCC($sAddress, $sName);
case "bcc":
return $this->Mail->AddBCC($sAddress, $sName);
}
return false;
}
示例14: send
function send()
{
$mail = new PHPMailer();
$mail->SMTPDebug = $this->SMTPDebug;
$mail->IsSMTP();
// set mailer to use SMTP
$mail->SMTPAuth = $this->SMTPAuth;
//設定SMTP需要驗證
$mail->SMTPSecure = $this->SMTPSecure;
// Gmail的SMTP主機需要使用SSL連線
$mail->Host = $this->Host;
//Gamil的SMTP主機
$mail->Port = $this->Port;
//Gamil的SMTP主機的SMTP埠位為465埠。
$mail->CharSet = $this->CharSet;
//設定郵件編碼
$mail->Username = $this->UserName;
$mail->Password = $this->Password;
$mail->From = $this->from;
$mail->FromName = $this->fromName;
foreach ($this->to as $to_address) {
$mail->AddAddress($to_address['email'], $to_address['name']);
}
foreach ($this->cc as $to_address) {
$mail->AddCC($to_address['email'], $to_address['name']);
}
foreach ($this->bcc as $to_address) {
$mail->AddBCC($to_address['email'], $to_address['name']);
}
$mail->AddReplyTo($this->from, $this->fromName);
$mail->WordWrap = 50;
// set word wrap to 50 characters
if (!empty($this->attachments)) {
foreach ($this->attachments as $attachment) {
if (empty($attachment['asfile'])) {
$mail->AddAttachment($attachment['filename']);
} else {
$mail->AddAttachment($attachment['filename'], $attachment['asfile']);
}
}
}
$mail->IsHTML(true);
// set email format to HTML
$mail->Subject = $this->subject;
$mail->Body = $this->html_body;
//設定郵件內容
$result = $mail->Send();
if ($result === false) {
$result = $mail->ErrorInfo;
}
return $result;
}
示例15: addAddressToMailer
public function addAddressToMailer($type, $addr)
{
if (empty($addr)) {
return;
}
$a = array_filter(array_map('trim', explode(',', $addr)));
foreach ($a as $address) {
switch ($type) {
case 'to':
$this->mail->AddAddress($address);
break;
case 'cc':
$this->mail->AddCC($address);
break;
case 'bcc':
$this->mail->AddBCC($address);
break;
case 'replyTo':
$this->mail->AddReplyTo($address);
}
}
}