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


PHP Message::addBcc方法代码示例

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


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

示例1: run

 public function run()
 {
     $transport = new SmtpTransport(new SmtpOptions(array('name' => $this->host, 'host' => $this->host, 'port' => $this->port, 'connection_config' => array('username' => $this->sender->getUsername(), 'password' => $this->sender->getPassword()))));
     if ($this->auth !== null) {
         $transport->getOptions()->setConnectionClass($this->auth);
     }
     $message = new Message();
     $message->addFrom($this->sender->getUsername())->setSubject($this->subject);
     if ($this->bcc) {
         $message->addBcc($this->recipients);
     } else {
         $message->addTo($this->recipients);
     }
     $body = new MimeMessage();
     if ($this->htmlBody == null) {
         $text = new MimePart($this->textBody);
         $text->type = "text/plain";
         $body->setParts(array($text));
     } else {
         $html = new MimePart($this->htmlBody);
         $html->type = "text/html";
         $body->setParts(array($html));
     }
     $message->setBody($body);
     $transport->send($message);
 }
开发者ID:rmukras,项目名称:ekda.org,代码行数:26,代码来源:EMailServiceWorker.php

示例2: fromWrappedMessage

 /**
  * @inheritDoc
  */
 public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
 {
     if (!$wrappedMessage instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('Not MailWrappedMessage');
     }
     $message = new Message();
     foreach ($wrappedMessage->getToRecipients() as $address) {
         $message->addTo($address);
     }
     foreach ($wrappedMessage->getCcRecipients() as $address) {
         $message->addCc($address);
     }
     foreach ($wrappedMessage->getBccRecipients() as $address) {
         $message->addBcc($address);
     }
     $message->setReplyTo($wrappedMessage->getReplyTo());
     $message->setFrom($wrappedMessage->getFrom());
     $message->setSubject($wrappedMessage->getSubject());
     if ($wrappedMessage->getContentText()) {
         $message->setBody($wrappedMessage->getContentText());
     }
     if ($wrappedMessage->getContentHtml()) {
         $html = new MimePart($wrappedMessage->getContentHtml());
         $html->type = "text/html";
         $message->setBody($body);
     }
     return $message;
 }
开发者ID:BespokeSupport,项目名称:MailWrapper,代码行数:31,代码来源:MessageTransformerZend.php

示例3: execute

 /**
  * Send email
  * 
  * @access public
  */
 public function execute()
 {
     $payload = $this->getContent();
     $from = $payload['from'];
     $to = $payload['to'];
     $subject = $payload['subject'];
     $body = $payload['body'];
     $message = new Message();
     $message->addTo($to)->addFrom($from)->setSubject($subject)->setBody($body);
     if (array_key_exists('bcc', $payload)) {
         $bcc = $payload['bcc'];
         $message->addBcc($bcc);
     }
     if (array_key_exists('cc', $payload)) {
         $cc = $payload['cc'];
         $message->addCc($cc);
     }
     $this->transport->send($message);
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:24,代码来源:SendEmailJob.php

示例4: sendMail

 public function sendMail($mail)
 {
     // Build the message body
     $mimeParts = array();
     foreach ($mail->getParts() as $part) {
         $mimePart = new MimePart($part->getContent());
         $mimePart->type = $part->getType();
         $mimeParts[] = $mimePart;
     }
     $body = new MimeMessage();
     $body->setParts($mimeParts);
     // Build the message.
     $message = new Mail\Message();
     $message->setBody($body);
     // Set the participants
     foreach ($mail->getParticipants() as $participant) {
         if ($participant->getComposition() == 'to') {
             $message->addTo($participant->getAddress(), $participant->getName());
         }
         if ($participant->getComposition() == 'cc') {
             $message->addCc($participant->getAddress(), $participant->getName());
         }
         if ($participant->getComposition() == 'bcc') {
             $message->addBcc($participant->getAddress(), $participant->getName());
         }
         if ($participant->getComposition() == 'from') {
             $message->addFrom($participant->getAddress(), $participant->getName());
         }
     }
     // Set the subject
     $message->setSubject($mail->getSubject());
     $contentType = $mail->getContentType();
     if ($contentType) {
         $message->getHeaders()->get('content-type')->setType($contentType);
     }
     // Create the transport and send.
     $transport = new SmtpTransport();
     $transport->setOptions(new SmtpOptions($this->options));
     $transport->send($message);
 }
开发者ID:srayner,项目名称:civmail,代码行数:40,代码来源:MailService.php

示例5: setShadowRecipients

 /**
  * Set the BCC and CC recipients to the email (they are the same for every email).
  *
  * @return Message
  */
 public function setShadowRecipients()
 {
     //Cc recipients
     foreach ($this->email->getCc() as $emailAddress => $contact) {
         if ($contact instanceof Contact) {
             $this->message->addCc($contact->getEmail(), $contact);
         } else {
             $this->message->addCc($emailAddress, $contact);
         }
     }
     //Bcc recipients
     foreach ($this->email->getBcc() as $emailAddress => $contact) {
         if ($contact instanceof Contact) {
             $this->message->addBcc($contact->getEmail(), $contact);
         } else {
             $this->message->addBcc($emailAddress, $contact);
         }
     }
     if (!is_null($this->email->getReplyTo())) {
         $this->message->addReplyTo($this->email->getReplyTo(), $this->email->getReplyToName());
     }
 }
开发者ID:debranova,项目名称:general,代码行数:27,代码来源:EmailService.php

示例6: send

 public function send($data = array(), $viewModel)
 {
     if ($viewModel instanceof ModelInterface) {
         $body = $this->renderModel($viewModel);
     } elseif (is_string($viewModel)) {
         $body = $this->renderText($viewModel);
     } else {
         throw new \Exception('Invalid viewModel for mail body');
     }
     $text = new MimePart('');
     $text->type = "text/plain";
     $html = new MimePart($body);
     $html->type = "text/html";
     $body_html = new MimeMessage();
     $body_html->setParts(array($text, $html));
     $mail = new Mail\Message();
     $mail->setEncoding("UTF-8");
     $mail->setBody($body_html);
     $mail->setFrom($this->_from_mail, $this->_from_name);
     $mail->addTo($data['to']);
     if (isset($data['cc'])) {
         $mail->addCc($data['cc']);
     }
     if (isset($data['bcc'])) {
         $mail->addBcc($data['bcc']);
     }
     if (isset($data['replyTo'])) {
         $mail->addReplyTo($data['replyTo'], $data['replyNameTo']);
     } else {
         $mail->addReplyTo($this->_from_mail, $this->_from_name);
     }
     if (isset($data['dkimSign'])) {
         $signer = $this->getController()->getServiceLocator()->get('DkimSigner');
         $signer->signMessage($mail);
     }
     $mail->setSubject($data['subject']);
     return $this->_transport->send($mail);
 }
开发者ID:renta,项目名称:EmailZF2,代码行数:38,代码来源:Mailer.php

示例7: testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders

 public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
 {
     $this->message->addTo('zf-devteam@zend.com', 'ZF DevTeam');
     $this->message->addFrom('matthew@zend.com', "Matthew Weier O'Phinney");
     $this->message->addCc('zf-contributors@lists.zend.com', 'ZF Contributors List');
     $this->message->addBcc('zf-crteam@lists.zend.com', 'ZF CR Team');
     $this->message->setSubject('This is a subject');
     $this->message->setEncoding('UTF-8');
     $test = $this->message->getHeaders()->toString();
     $expected = '=?UTF-8?Q?ZF=20DevTeam?=';
     $this->assertContains($expected, $test);
     $this->assertContains('<zf-devteam@zend.com>', $test);
     $expected = "=?UTF-8?Q?Matthew=20Weier=20O'Phinney?=";
     $this->assertContains($expected, $test, $test);
     $this->assertContains('<matthew@zend.com>', $test);
     $expected = '=?UTF-8?Q?ZF=20Contributors=20List?=';
     $this->assertContains($expected, $test);
     $this->assertContains('<zf-contributors@lists.zend.com>', $test);
     $expected = '=?UTF-8?Q?ZF=20CR=20Team?=';
     $this->assertContains($expected, $test);
     $this->assertContains('<zf-crteam@lists.zend.com>', $test);
     $expected = 'Subject: =?UTF-8?Q?This=20is=20a=20subject?=';
     $this->assertContains($expected, $test);
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:24,代码来源:MessageTest.php

示例8: sendemail


//.........这里部分代码省略.........
         default:
             break;
     }
     $options = new SmtpOptions($smtp_args);
     $transport->setOptions($options);
     $message = new Message();
     $message->addFrom($fromemail, $fromname);
     if (!empty($email)) {
         $message_id = $reference_id = $in_reply_to = '';
         if ('comment' == $email->refrence_type) {
             $message_id = get_comment_meta($email->refrence_id, '_rtlib_messageid', true);
             $reference_id = get_comment_meta($email->refrence_id, '_rtlib_references', true);
             if (empty($message_id)) {
                 $comment = get_comment($email->refrence_id);
                 $post_id = $comment->comment_post_ID;
             }
         } else {
             if ('post' == $email->refrence_type) {
                 $post_id = $email->refrence_id;
             }
         }
         if (isset($post_id)) {
             $reference_id = get_post_meta($post_id, '_rtlib_references', true);
             $message_id = rtmb_get_reply_to_from_ref_id($reference_id);
             $reply_to = apply_filters('rtlib_reply_to_header', '', $fromemail, $post_id);
             if (!empty($reply_to)) {
                 $message->addCustomeHeader('Reply-To', trim($reply_to));
             }
         }
         //Get reply to header
         if (!empty($message_id)) {
             $message->addCustomeHeader('In-Reply-To', trim($message_id));
         }
         //Get References header
         if (!empty($message_id)) {
             $reference_id = rtmb_add_message_id_in_ref_id($message_id, $reference_id);
         }
         if (!empty($reference_id)) {
             $reference_ids = rtmb_get_reference_id_array($reference_id);
             $_reference_id = implode(' ', $reference_ids);
             $message->addCustomeHeader('References', $_reference_id);
         }
         // Add x-mailer
         if (!empty($email->refrence_id)) {
             $message->addCustomeHeader('X-Mailer', 'rtCamp-mail-lib');
             if ('comment' == $email->refrence_type) {
                 $comment = get_comment($email->refrence_id);
                 $post_id = $comment->comment_post_ID;
             } else {
                 $post_id = $email->refrence_id;
             }
             $new_message_id = rtmb_generate_message_id($post_id, $email->id);
             rtmb_add_message_id_in_ref_id($new_message_id, $reference_id, $post_id);
             $message->addCustomeHeader('Message-ID', $new_message_id);
         }
     }
     //$mail->setFrom($fromemail);
     $message->setSubject(stripslashes_deep(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')));
     //$mail->setSubject($subject);
     if (!empty($toEmail)) {
         foreach ($toEmail as $temail) {
             //$mail->addTo($temail["email"], isset($temail["name"]) ? $temail["name"] : '');
             $message->addTo($temail['email'], isset($temail['name']) ? $temail['name'] : '');
         }
     }
     if (!empty($ccEmail)) {
         foreach ($ccEmail as $temail) {
             //$mail->addCc($temail["email"], isset($temail["name"]) ? $temail["name"] : '');
             $message->addCc($temail['email'], isset($temail['name']) ? $temail['name'] : '');
         }
     }
     if (!empty($bccEmail)) {
         foreach ($bccEmail as $temail) {
             if (isset($temail['email'])) {
                 $message->addBcc($temail['email'], isset($temail['name']) ? $temail['name'] : '');
             }
         }
     }
     // create a MimeMessage object that will hold the mail body and any attachments
     $bodyPart = new MimeMessage();
     $bodyMessage = new MimePart($body);
     $bodyMessage->type = 'text/html';
     $bodyMessage->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
     $bodyPart->addPart($bodyMessage);
     if (!empty($attachemnts) && is_array($attachemnts)) {
         foreach ($attachemnts as $attach) {
             $file_array = explode('/', $attach);
             $fileName = $file_array[count($file_array) - 1];
             $attachment = new MimePart(file_get_contents($attach));
             $attachment->type = rtmb_get_mime_type($attach);
             $attachment->filename = $fileName;
             $attachment->encoding = Zend\Mime\Mime::ENCODING_BASE64;
             $attachment->disposition = Zend\Mime\Mime::DISPOSITION_ATTACHMENT;
             $bodyPart->addPart($attachment);
         }
     }
     $message->setBody($bodyPart);
     $transport->send($message);
     return true;
 }
开发者ID:neerukoul,项目名称:rtbiz,代码行数:101,代码来源:class-rt-zend-mail.php

示例9: testMsgHandleUidSearch

 /**
  * @group medium
  */
 public function testMsgHandleUidSearch()
 {
     $path1 = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $log = new Logger('test_application');
     #$log->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
     $server = new Server('', 0);
     $server->setLog($log);
     $server->init();
     $storage1 = new DirectoryStorage();
     $storage1->setPath($path1);
     $server->addStorage($storage1);
     $client = new Client();
     $client->setServer($server);
     $client->setId(1);
     $msg = $client->msgHandle('17 uid search');
     $this->assertEquals('17 NO uid failure' . Client::MSG_SEPARATOR, $msg);
     $client->setStatus('hasAuth', true);
     $msg = $client->msgHandle('17 uid search');
     $this->assertEquals('17 NO No mailbox selected.' . Client::MSG_SEPARATOR, $msg);
     $client->msgHandle('6 select INBOX');
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 1');
     $message->setBody('my_body');
     $server->addMail($message, null, null, false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 2');
     $message->setBody('my_body');
     $server->addMail($message, null, array(Storage::FLAG_ANSWERED), false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->addBcc('steve@apple.com');
     $message->setSubject('my_subject 3');
     $message->setBody('my_body');
     $server->addMail($message, null, null, false);
     $headers = new Headers();
     $headers->addHeader(Date::fromString('Date: ' . date('r', mktime(0, 0, 0, 2, 21, 1987))));
     $message = new Message();
     $message->setHeaders($headers);
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 4');
     $message->setBody('my_body');
     $server->addMail($message, null, null, false);
     $message = new Message();
     $message->setHeaders($headers);
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 5');
     $message->setBody('my_body');
     $server->addMail($message, null, null, false);
     $headers = new Headers();
     $headers->addHeader(Date::fromString('Date: ' . date('r', mktime(0, 0, 0, 11, 20, 1986))));
     $message = new Message();
     $message->setHeaders($headers);
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 6');
     $message->setBody('hello world');
     $server->addMail($message, null, null, false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 7');
     $message->setBody('my_body');
     $server->addMail($message, null, array(Storage::FLAG_DELETED), false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 8');
     $message->setBody('my_body');
     $server->addMail($message, null, array(Storage::FLAG_DRAFT), false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 9');
     $message->setBody('my_body');
     $server->addMail($message, null, array(Storage::FLAG_FLAGGED), false);
     $message = new Message();
     $message->addFrom('test@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 10');
     $message->setBody('my_body');
     $server->addMail($message, null, null, false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
     $message->setSubject('my_subject 11');
     $message->setBody('my super fancy long body for testing the size');
     $server->addMail($message, null, null, false);
     $message = new Message();
     $message->addFrom('dev1@fox21.at');
     $message->addTo('dev2@fox21.at');
//.........这里部分代码省略.........
开发者ID:thefox,项目名称:imapd,代码行数:101,代码来源:ClientTest.php

示例10: send

 public function send()
 {
     # differ the following scenarios:
     # - plain text email
     # - plain text email with 1 or n attachments
     # - html email with text alternative
     # - html email with text alternative and 1 or n attachments
     $content = new Mime\Message();
     if (!$this->isHtmlMessage()) {
         $content->addPart($this->getTextMessage());
     } else {
         $content->addPart($this->getTextMessage());
         $content->addPart($this->getHtmlMessage());
     }
     if (count($this->getAttachments()) == 0) {
         $body = $content;
     } else {
         $contentPart = new Mime\Part($content->generateMessage());
         $contentPart->type = 'multipart/alternative;' . PHP_EOL . ' boundary="' . $content->getMime()->boundary() . '"';
         $body = new Mime\Message();
         $body->addPart($contentPart);
         foreach ($this->getAttachments() as $att) {
             $body->addPart($att);
         }
     }
     $message = new Mail\Message();
     $message->setEncoding('utf-8');
     $message->setBody($body);
     if ($this->isHtmlMessage()) {
         if (count($this->getAttachments()) == 0) {
             $message->getHeaders()->get('content-type')->addParameter('charset', 'utf-8')->setType('multipart/alternative');
         } else {
             $message->getHeaders()->get('content-type')->addParameter('charset', 'utf-8')->setType('multipart/mixed');
             // Important to get all attachments into this email.
         }
     } else {
         $message->getHeaders()->get('content-type')->addParameter('charset', 'utf-8')->setType('text/plain');
     }
     foreach ($this->getTo() as $user) {
         $message->addTo($user->getEmail());
     }
     foreach ($this->getCc() as $user) {
         $message->addCc($user->getEmail());
     }
     foreach ($this->getBcc() as $user) {
         $message->addBcc($user->getEmail());
     }
     $message->addFrom($this->getFrom());
     $message->setSubject($this->getSubject());
     $transport = new Mail\Transport\Sendmail();
     $transport->send($message);
 }
开发者ID:odegroot,项目名称:ers,代码行数:52,代码来源:EmailService.php

示例11: setBcc

 function setBcc($address)
 {
     foreach ((array) $address as $bcc) {
         $this->mail->addBcc($bcc);
     }
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:6,代码来源:tikimaillib.php

示例12: sendEmail

 public function sendEmail($template = 'message', $emailOptions = array())
 {
     $emailOptions = array_merge($this->config, $emailOptions);
     $content = $this->renderEmail($template, $emailOptions);
     if ($emailOptions['debug']) {
         $displays = array();
         foreach ($emailOptions as $key => $value) {
             if ($key !== 'message' && $key != 'attachments') {
                 if (!is_object($value)) {
                     $displays[] = $key . ': <strong>' . (is_array($value) ? implode(',', $value) : $value) . '</strong>';
                 } else {
                     $displays[] = $key . ': <strong>OBJ</strong>';
                 }
             }
         }
         echo '<div style="
                     background-color: #444; 
                     padding: 50px;
                     box-shadow: 1px 1px 10px rgba(0,0,0,0.8) inset;
             ">
                 <div style="
                             width:80%; 
                             margin:10px auto; 
                             background-color:#ffffff; 
                             box-shadow:1px 2px 5px rgba(0,0,0,0.5);
                             padding: 15px;
                 " >
                     ' . implode(' ; ', $displays) . '
                 </div>
                 <div style="
                             width:80%; 
                             margin:10px auto; 
                             background-color:#ffffff; 
                             box-shadow:1px 2px 5px rgba(0,0,0,0.5);
                 " >' . $content . '</div>' . (isset($emailOptions['attachments']) && $emailOptions['attachments'] ? '<div style="
                             width:80%; 
                             margin:10px auto; 
                             background-color:#ffffff; 
                             box-shadow:1px 2px 5px rgba(0,0,0,0.5);
                             padding: 15px;
                 " >Mit Anhang</div>' : '') . '</div>';
     }
     $attachments = isset($emailOptions['attachments']) && $emailOptions['attachments'] && is_array($emailOptions['attachments']) ? $emailOptions['attachments'] : array();
     $message = new Message();
     $message->addTo($emailOptions['to']);
     $message->addFrom($emailOptions['from']);
     $message->setSubject($emailOptions['subject']);
     if ($emailOptions['bcc']) {
         $message->addBcc($emailOptions['bcc']);
     }
     if ($emailOptions['cc']) {
         $message->addCc($emailOptions['cc']);
     }
     if ($this->html) {
         // HTML part
         $htmlPart = new MimePart($content);
         $htmlPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
         $htmlPart->type = "text/html; charset=UTF-8";
     }
     // Plain text part
     $textPart = new MimePart(strip_tags($content));
     $textPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
     $textPart->type = "text/plain; charset=UTF-8";
     $body = new MimeMessage();
     if ($attachments) {
         // With attachments, we need a multipart/related email. First part
         // is itself a multipart/alternative message
         $content = new MimeMessage();
         $content->addPart($textPart);
         if ($this->html) {
             $content->addPart($htmlPart);
         }
         $contentPart = new MimePart($content->generateMessage());
         $contentPart->type = "multipart/alternative;\n boundary=\"" . $content->getMime()->boundary() . '"';
         $body->addPart($contentPart);
         $messageType = 'multipart/related';
         // Add each attachment
         foreach ($attachments as $thisAttachment) {
             $attachment = new MimePart($thisAttachment['buffer']);
             $attachment->filename = $thisAttachment['filename'];
             $attachment->type = Mime::TYPE_OCTETSTREAM;
             $attachment->encoding = Mime::ENCODING_BASE64;
             $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
             $body->addPart($attachment);
         }
     } else {
         // No attachments, just add the two textual parts to the body
         if ($this->html) {
             $body->setParts(array($textPart, $htmlPart));
             $messageType = 'multipart/alternative';
         } else {
             $body->setParts(array($textPart));
             $messageType = 'text/plain';
         }
     }
     // attach the body to the message and set the content-type
     $message->setBody($body);
     $message->getHeaders()->get('content-type')->setType($messageType);
     $message->setEncoding('UTF-8');
     if ($emailOptions['send']) {
//.........这里部分代码省略.........
开发者ID:CasasoftCH,项目名称:casamodules,代码行数:101,代码来源:EmailService.php

示例13: previewAction

 public function previewAction()
 {
     $this->updateLayoutWithIdentity();
     if ($this->disallowRankLessThan(User::RANK_GENERAL)) {
         return false;
     }
     $session = new SessionContainer('NightsWatch\\Announcement\\Create');
     if (empty($session->title)) {
         $this->redirect()->toRoute('home', ['controller' => 'announcement', 'action' => 'create']);
         return false;
     }
     $announcement = new Announcement();
     $announcement->title = $session->title;
     $announcement->content = $session->content;
     $announcement->user = $this->getIdentityEntity();
     $announcement->timestamp = new \DateTime();
     $announcement->lowestReadableRank = $session->rank;
     if ($this->getRequest()->isPost()) {
         $this->getEntityManager()->persist($announcement);
         $this->getEntityManager()->flush();
         $userRepo = $this->getEntityManager()->getRepository('NightsWatch\\Entity\\User');
         $criteria = Criteria::create()->where(Criteria::expr()->gte('rank', $announcement->lowestReadableRank));
         /** @var User[] $users */
         $users = $userRepo->matching($criteria);
         $mail = new Message();
         $mail->setSubject('[NightsWatch] ' . $announcement->title);
         $mail->setFrom(new Address('noreply@minez-nightswatch.com', $announcement->user->username));
         $mail->setTo(new Address('members@minez-nightswatch.com', 'Members'));
         $mail->setEncoding('UTF-8');
         // Create a signature for email
         $title = trim($announcement->user->getTitleOrRank());
         $announcement->content = $announcement->content .= "\n\n" . $announcement->user->username . "  \n" . '*' . $title . '*';
         $body = new MimeBody();
         $bodyHtml = new MimePart($announcement->getParsedContent());
         $bodyHtml->type = Mime::TYPE_HTML;
         $bodyText = new MimePart($announcement->content);
         $bodyText->type = Mime::TYPE_TEXT;
         $body->setParts([$bodyHtml, $bodyText]);
         $mail->setBody($body);
         foreach ($users as $user) {
             if ($user->emailNotifications & User::EMAIL_ANNOUNCEMENT > 0) {
                 $mail->addBcc(new Address($user->email, $user->username));
             }
         }
         $transport = new Sendmail();
         $transport->send($mail);
         $session->title = '';
         $this->redirect()->toRoute('id', ['controller' => 'announcement', 'id' => $announcement->id]);
         return false;
     }
     return new ViewModel(['announcement' => $announcement]);
 }
开发者ID:jomo,项目名称:TheNightsWatch2,代码行数:52,代码来源:AnnouncementController.php

示例14: addBccRecipient

 /**
  * @param string $emailAddress
  */
 public function addBccRecipient($emailAddress)
 {
     $this->message->addBcc($emailAddress);
 }
开发者ID:WasabiLib,项目名称:Mail,代码行数:7,代码来源:Mail.php

示例15: sendMail

 public function sendMail($mailOptions = array())
 {
     $this->_setMailOptions($mailOptions);
     $text = new Part($this->mailBody);
     $text->type = Mime::TYPE_HTML;
     $mailBodyParts = new MimeMessage();
     $mailBodyParts->addPart($text);
     if (!empty($this->fileNames) && !empty($this->filePaths)) {
         foreach ($this->filePaths as $key => $filePath) {
             $file = new Part(file_get_contents($filePath));
             $file->encoding = Mime::ENCODING_BASE64;
             $file->type = finfo_file(finfo_open(), $filePath, FILEINFO_MIME_TYPE);
             $file->disposition = Mime::DISPOSITION_ATTACHMENT;
             $file->filename = $this->fileNames[$key];
             $mailBodyParts->addPart($file);
         }
     }
     $options = array();
     if ($this->useSMTP === false) {
         $options = new SmtpOptions(array("name" => $this->smtpName, "host" => $this->smtpHost, "port" => $this->smtpPort));
     } else {
         $options = new SmtpOptions(array('name' => $this->smtpName, 'host' => $this->smtpHost, 'port' => $this->smtpPort, 'connection_class' => $this->smtpConnectionClass, 'connection_config' => array('ssl' => $this->smtpSsl, 'username' => $this->smtpUsername, 'password' => $this->smtpPassword)));
     }
     $mail = new Message();
     $mail->setBody($mailBodyParts);
     $mail->setFrom($this->mailFrom, $this->mailFromNickName);
     $mail->addTo($this->mailTo);
     if (!empty($this->mailCc)) {
         $mail->addCc($this->mailCc);
     }
     if (!empty($this->mailBcc)) {
         $mail->addBcc($this->mailBcc);
     }
     $mail->setSubject($this->mailSubject);
     $transport = new SmtpTransport();
     $transport->setOptions($options);
     $emailLogInfo = array('email_to' => $this->mailTo, 'email_from' => $this->mailFrom, 'email_body' => $this->mailBody, 'email_subject' => $this->mailSubject, 'sender_type' => $this->mailSenderType);
     $emailSend = 0;
     try {
         $transport->send($mail);
         $emailSend = 1;
     } catch (\Exception $e) {
         $emailLogInfo['email_error'] = $e->getMessage();
         throw $e;
     }
     return $emailSend;
 }
开发者ID:arvind2110,项目名称:zf2mail,代码行数:47,代码来源:Mail.php


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