当前位置: 首页>>代码示例>>PHP>>正文


PHP Mail_mime::addBcc方法代码示例

本文整理汇总了PHP中Mail_mime::addBcc方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mime::addBcc方法的具体用法?PHP Mail_mime::addBcc怎么用?PHP Mail_mime::addBcc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mail_mime的用法示例。


在下文中一共展示了Mail_mime::addBcc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendEmail

 function sendEmail()
 {
     foreach ($this->to as $to) {
         $headers = array('From' => SMTP_FROM_NAME . "<" . SMTP_FROM . ">", 'To' => $to, 'Subject' => $this->subject);
         $mime = new Mail_mime($this->NEW_LINE);
         if ($this->body == null) {
             if ($this->compiledTXT != null && strlen($this->compiledTXT) > 0) {
                 $mime->setTXTBody($this->compiledTXT);
             }
             if ($this->compiledHTML != null && strlen($this->compiledHTML) > 0) {
                 $mime->setHTMLBody($this->compiledHTML);
             }
         } else {
             $mime->setTXTBody($this->body);
         }
         foreach ($this->cc as $email) {
             $mime->addCc($email);
         }
         foreach ($this->bcc as $email) {
             $mime->addBcc($email);
         }
         if (is_array($this->files) && count($this->files) > 0) {
             foreach ($this->files as $file) {
                 $mime->addAttachment($file["path"], $file["content-type"]);
             }
         }
         $body = $mime->get();
         $headers = $mime->headers($headers);
         $string = "";
         foreach ($headers as $key => $value) {
             $string .= "{$key}: {$value}\r\n";
         }
         $smtpOptions = array('host' => SMTP_HOST, 'port' => SMTP_PORT);
         if (defined("SMTP_USER_NAME") && defined("SMTP_PASSWORD")) {
             $smtpOptions['auth'] = true;
             $smtpOptions['username'] = SMTP_USER_NAME;
             $smtpOptions['password'] = SMTP_PASSWORD;
         }
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $smtp = Mail::factory('smtp', $smtpOptions);
         $success = $smtp->send($to, $headers, $body);
         if ($success !== true) {
             throw new PEARErrorException($success);
         }
     }
 }
开发者ID:hikirsch,项目名称:obj_tmpl_mailer,代码行数:46,代码来源:TemplateEmail.php

示例2: send

 public function send()
 {
     $fullFrom = "'" . $this->fromName . "' <" . $this->from . ">";
     $fullFrom = $this->from;
     $cc = NULL;
     $bcc = NULL;
     if (is_array($this->to)) {
         $entries = count($this->to);
         if ($entries > 1) {
             $to = "";
             $counter = 0;
             foreach ($this->to as $address) {
                 $chk = $counter + 1;
                 if ($chk == $entries) {
                     $to .= $address;
                 } else {
                     $to .= $address . ',';
                 }
                 $counter++;
             }
         } else {
             $to = $this->to[0];
         }
     } else {
         $to = $this->to;
     }
     $recipients = $to;
     // Add CC
     if (isset($this->cc)) {
         if (is_array($this->cc)) {
             $entries = count($this->cc);
             $cc = "";
             $counter = 0;
             foreach ($this->cc as $address) {
                 $chk = $counter + 1;
                 if ($chk == $entries) {
                     $cc .= $address;
                 } else {
                     $cc .= $address . ',';
                 }
                 $counter++;
             }
         } else {
             $cc = $this->cc;
         }
         $recipients = $recipients . "," . $cc;
     }
     // Add CC
     if (isset($this->bcc)) {
         if (is_array($this->bcc)) {
             $entries = count($this->bcc);
             $bcc = "";
             $counter = 0;
             foreach ($this->bcc as $address) {
                 $chk = $counter + 1;
                 if ($chk == $entries) {
                     $bcc .= $address;
                 } else {
                     $bcc .= $address . ',';
                 }
                 $counter++;
             }
         } else {
             $bcc = $this->cc;
         }
         $recipients = $recipients . "," . $bcc;
     }
     // To Blind CC (aka, BCC) an address, simply add the address to the
     //    $recipients, but not to any of the $headers.
     $headers = array('From' => $fullFrom, 'Return-Path' => $this->from, 'To' => $to, 'Cc' => $cc, 'Subject' => $this->subject);
     //setting values for htmlMail
     switch ($this->useHTMLMail) {
         case TRUE:
             $objMime = new Mail_mime();
             $objMime->addCc($this->cc);
             $objMime->addBcc($this->bcc);
             $objMime->setTXTBody($this->body);
             $objMime->setHTMLBody($this->htmlbody);
             $this->body = $objMime->get();
             $headers = $objMime->headers($headers);
             //
             $smptParams = array('MIME Version' => '1.0', 'Content-Type' => 'text/html; charset=ISO-8859-1', 'host' => $this->host, 'port' => $this->port, 'auth' => $this->smtpAuth, 'username' => $this->username, 'password' => $this->password);
             //
             $smtp = Mail::factory('smtp', $smptParams);
             break;
         default:
             $smtp = Mail::factory('smtp', array('host' => $this->host, 'port' => $this->port, 'auth' => $this->smtpAuth, 'username' => $this->username, 'password' => $this->password));
             break;
     }
     $mail = $smtp->send($recipients, $headers, $this->body);
     if (PEAR::isError($mail)) {
         echo "<p>" . $mail->getMessage() . "</p>";
         return FALSE;
     } else {
         return TRUE;
     }
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:97,代码来源:mailer_class_inc.php

示例3:

    $client->setAccessToken($_SESSION['access_token']);
} else {
    $loginUrl = $client->createAuthUrl();
}
// Check if we have an access token ready for API calls
try {
    if (isset($_SESSION['access_token']) && $client->getAccessToken()) {
        // Make API Calls
        if (isset($_POST['send'])) {
            $to = $_POST['to'];
            $bcc = $_POST['bcc'];
            $cc = $_POST['cc'];
            $body = $_POST['message'];
            $subject = $_POST['subject'];
            $mime->addTo($to);
            $mime->addBcc($bcc);
            $mime->addCc($cc);
            $mime->setTXTBody($body);
            $mime->setHTMLBody($body);
            $mime->setSubject($subject);
            $message_body = $mime->getMessage();
            $encoded_message = base64url_encode($message_body);
            // Gmail Message Body
            $message = new Google_Service_Gmail_Message();
            $message->setRaw($encoded_message);
            // Send the Email
            $email = $service->users_messages->send('me', $message);
            if ($email->getId()) {
                $notice = '<div class="alert alert-success">Email Sent successfully!</div>';
            } else {
                $notice = '<div class="alert alert-danger">Oops...something went wrong, try again later</div>';
开发者ID:veslo1,项目名称:gmail-php-starter,代码行数:31,代码来源:gmail.php

示例4: process

 function process()
 {
     //include PEAR mailing class
     include_once 'Mail.php';
     include_once 'Mail/mime.php';
     $mime = new Mail_mime($this->crlf);
     $mail = Mail::factory('mail');
     //set encoding
     $mime->_build_params['head_charset'] = $mime->_build_params['text_charset'] = $mime->_build_params['html_charset'] = $this->charset;
     //set from, subject
     $hdrs = array('From' => $this->from, 'Subject' => $this->subject);
     //set to
     if (count($this->adresses['to']) > 0) {
         $to = implode(', ', $this->adresses['to']);
     } else {
         return false;
     }
     //set cc
     if (count($this->adresses['cc']) > 0) {
         $mime->addCc(implode(', ', $this->adresses['cc']));
     }
     //set bcc
     if (count($this->adresses['bcc']) > 0) {
         $mime->addBcc(implode(', ', $this->adresses['bcc']));
     }
     //add attachments
     foreach ($this->attachments as $v) {
         $mime->addAttachment($v['file'], $v['type'], $v['name']);
     }
     //set message
     $mime->setTXTBody($this->txt_body);
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail = Mail::factory('mail');
     return $mail->send($to, $hdrs, $body);
     //$mail->send(array($to), 'mail');
 }
开发者ID:rbraband,项目名称:sefrengo,代码行数:37,代码来源:Mail.php

示例5: send

 /**
  * Send the mail, based on the class' properties.
  *
  * @return bool
  */
 public function send()
 {
     // Validate properties and throw an exception for errors
     $this->validate();
     // Add text variant when only HTTML is provided
     if ($this->messageTxt === null) {
         $this->messageTxt = html_entity_decode($this->messageHtml);
     }
     // Send the mail
     $headers = ['From' => $this->from, 'Subject' => $this->subject];
     $mime = new \Mail_mime(PHP_EOL);
     $mime->setTXTBody($this->messageTxt);
     $mime->setHTMLBody($this->messageHtml);
     if (!empty($this->cc)) {
         foreach ($this->cc as $address) {
             $mime->addCc($address);
         }
     }
     if (!empty($this->bcc)) {
         foreach ($this->bcc as $address) {
             $mime->addBcc($address);
         }
     }
     $result = (new \Mail_mail())->send($this->address, $mime->headers($headers), $mime->get(['text_charset' => 'utf-8', 'html_charset' => 'utf-8']));
     return !is_a($result, 'PEAR_Error');
 }
开发者ID:Soneritics,项目名称:Framework,代码行数:31,代码来源:Mail.php

示例6: main

 public function main()
 {
     $mime = new Mail_mime();
     // Add message as html or plain text
     if ($this->isHtml()) {
         $mime->setHTMLBody($this->getMessage());
     } else {
         $mime->setTXTBody($this->getMessage());
     }
     // Add recipients
     foreach ($this->getTo() as $recipient) {
         $mime->addTo($recipient);
     }
     foreach ($this->getCc() as $recipient) {
         $mime->addCc($recipient);
     }
     foreach ($this->getBcc() as $recipient) {
         $mime->addBcc($recipient);
     }
     // Add sender and subject
     $mime->setFrom($this->getFrom());
     $mime->setSubject($this->getSubject());
     // Send the damnedable thing!
     $body = $mime->get();
     $headers = $mime->headers();
     $this->log("Assembled headers: " . print_r($headers, true));
     $mail =& Mail::factory('mail');
     $status = $mail->send($this->getTo(), $headers, $body);
     // Handle the outcome of our send attempt
     if ($status === true) {
         $recipCount = count($this->getTo()) + count($this->getCc()) + count($this->getBcc());
         $this->log("Sent MIME mail to {$recipCount} recipients");
     } else {
         throw new BuildException('Failed to send MIME mail: ' . $status->getMessage());
     }
 }
开发者ID:nlmdev,项目名称:phingistrano-monkeypatch,代码行数:36,代码来源:MimeMailTask.php


注:本文中的Mail_mime::addBcc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。