本文整理汇总了PHP中Zend\Mail\Message::setBcc方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setBcc方法的具体用法?PHP Message::setBcc怎么用?PHP Message::setBcc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::setBcc方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
/**
* @param string $subject
* @param string $message
* @param null|string|array $to
* @param null|string|array $cc
* @param null|string|array $bcc
* @return array
*/
public function sendMail($subject, $message, $to = null, $cc = null, $bcc = null)
{
$return = array('success' => true, 'msg' => null);
$partBody = new MimePart($this->getPartHeader() . $message . $this->getPartFooter());
$partBody->type = Mime::TYPE_HTML;
$partBody->charset = 'utf-8';
$this->body->setParts(array($partBody));
$subject = '[' . APPLICATION_NAME . '] ' . $subject;
$mail = new Message();
$mail->addFrom(self::FROM);
$mail->setSubject($subject);
$mail->setBody($this->body);
$mail->setTo($to);
if ($cc) {
$mail->setCc($cc);
}
if ($bcc) {
$mail->setBcc($bcc);
}
try {
$this->transport->send($mail);
} catch (\Exception $e) {
$return['success'] = false;
$return['msg'] = _('mail.message.not_sent');
//throw new \Exception($e->getMessage(), $e->getCode());
}
return $return;
}
示例2: testCanSetBccListFromAddressList
public function testCanSetBccListFromAddressList()
{
$list = new AddressList();
$list->add('zf-devteam@zend.com');
$this->message->addBcc('fw-announce@lists.zend.com');
$this->message->setBcc($list);
$bcc = $this->message->getBcc();
$this->assertEquals(1, count($bcc));
$this->assertFalse($bcc->has('fw-announce@lists.zend.com'));
$this->assertTrue($bcc->has('zf-devteam@zend.com'));
}
示例3: createMessage
/**
* @param ZendMailInterface $mail
*
* @return Mail\Message
*/
protected function createMessage(ZendMailInterface $mail)
{
$message = new Mail\Message();
$message->getHeaders()->addHeaders($mail->getHeaders());
$message->setTo($mail->getTo());
$message->setCc($mail->getCc());
$message->setBcc($mail->getBcc());
$message->setFrom($mail->getFrom());
$message->setReplyTo($mail->getReplyTo());
$message->setSubject($mail->getSubject());
$message->setBody($this->messageCreator->createMessage($mail));
return $message;
}
示例4: sendMail
public function sendMail()
{
if (false === $this->checkMailValidity()) {
throw new \InvalidArgumentException('E-Mail can not be sent as the required fields where not filled in.');
}
$mimeBody = new MimeMessage();
if ($this->mailBodyHtml instanceof ViewModel) {
$htmlBodyPart = new MimePart($this->createBodyFromViewModel($this->mailBodyHtml));
$htmlBodyPart->charset = $this->mailCharset;
$htmlBodyPart->encoding = $this->mailEncoding;
$htmlBodyPart->type = 'text/html';
$mimeBody->addPart($htmlBodyPart);
}
if ($this->mailBodyText instanceof ViewModel) {
$textBodyPart = new MimePart($this->createBodyFromViewModel($this->mailBodyText));
$textBodyPart->charset = $this->mailCharset;
$textBodyPart->encoding = $this->mailEncoding;
$textBodyPart->type = 'text/plain';
$mimeBody->addPart($textBodyPart);
}
$mailMessage = new MailMessage();
$mailMessage->setBody($mimeBody);
$mailMessage->setEncoding($this->mailEncoding);
$mailMessage->setFrom($this->mailFrom);
$mailMessage->setSender($this->mailFrom);
$mailMessage->setTo($this->mailTo);
if ($this->mailBcc != '') {
$mailMessage->setBcc($this->mailBcc);
}
if ($this->mailCc != '') {
$mailMessage->setCc($this->mailCc);
}
$mailMessage->setSubject($this->mailSubject);
if (2 <= count($mimeBody->getParts())) {
$mailMessage->getHeaders()->get('content-type')->setType('multipart/alternative');
}
try {
$this->transport->send($mailMessage);
return true;
} catch (\Exception $e) {
throw new \Exception($e);
}
}
示例5: convert
/**
*
* @param Message $message
* @return ZendMessage
*/
public static function convert(Message $message)
{
$mailMessage = new ZendMessage();
$mailMessage->setSubject($message->getSubject());
$mailMessage->setFrom($message->getFrom());
$mailMessage->setTo($message->getTo());
$mailMessage->setCc($message->getCc());
$mailMessage->setBcc($message->getBcc());
$mailMessage->setReplyTo($message->getReplyTo());
$mailMessage->getHeaders()->addHeaders($message->getHeaders());
if ($mailMessage->getSender()) {
$mailMessage->setSender($message->getSender());
}
if ($message->isMultipart()) {
$mimePart = new MimeMessage();
if ($message->getBodyHtml()) {
$part = new Part($message->getBodyHtml());
$part->charset = $message->getCharset();
$part->encoding = $message->getEncoding();
$part->type = Mime::TYPE_HTML;
$mimePart->addPart($part);
}
if ($message->getBodyText()) {
$part = new Part($message->getBodyText());
$part->charset = $message->getCharset();
$part->encoding = $message->getEncoding();
$part->type = Mime::TYPE_TEXT;
$mimePart->addPart($part);
}
foreach ($message->getAttachments() as $attachment) {
$mimePart->addPart($attachment->asMimePart());
}
foreach ($message->getParts() as $part) {
$mimePart->addPart($part);
}
$mailMessage->setBody($mimePart);
} else {
$mailMessage->getHeaders()->addHeaderLine('Content-Type', $message->getContentType());
$mailMessage->setEncoding($message->getEncoding());
$mailMessage->setBody($message->getFilledBody());
}
return $mailMessage;
}
示例6: getMessage
/**
* @param string $tpl
* @param array $data
* @return Message
*/
public function getMessage($tpl, array $data)
{
$mail = new Message();
$mail->setEncoding('UTF-8');
if (isset($data['encoding'])) {
$mail->setEncoding($data['encoding']);
}
if (isset($data['from_address'])) {
if (isset($data['from_name'])) {
$mail->setFrom($data['from_address'], $data['from_name']);
} else {
$mail->setFrom($data['from_address']);
}
}
if (isset($data['to'])) {
if (isset($data['to_name'])) {
$mail->setTo($data['to'], $data['to_name']);
} else {
$mail->setTo($data['to']);
}
}
if (isset($data['cc'])) {
$mail->setCc($data['cc']);
}
if (isset($data['bcc'])) {
$mail->setBcc($data['bcc']);
}
if (isset($data['subject'])) {
$mail->setSubject($data['subject']);
}
if (isset($data['sender'])) {
$mail->setSender($data['sender']);
}
if (isset($data['replyTo'])) {
$mail->setReplyTo($data['replyTo']);
}
$content = $this->renderMail($tpl, $data);
$mail->setBody($content);
$mail->getHeaders()->addHeaderLine('Content-Type', 'text/html; charset=UTF-8')->addHeaderLine('Content-Transfer-Encoding', '8bit');
return $mail;
}
示例7: createMessage
/**
* @return Message
*/
protected function createMessage()
{
$options = $this->mailOptions->getMessageOptions();
// Prepare Mail Message
$message = new Message();
$from = $options->getFrom();
if (!empty($from)) {
$message->setFrom($from, $options->getFromName());
}
$replyTo = $options->getReplyTo();
if (!empty($replyTo)) {
$message->setReplyTo($replyTo, $options->getReplyToName());
}
$to = $options->getTo();
if (!empty($to)) {
$message->setTo($to);
}
$cc = $options->getCc();
if (!empty($cc)) {
$message->setCc($cc);
}
$bcc = $options->getBcc();
if (!empty($bcc)) {
$message->setBcc($bcc);
}
return $message;
}
示例8: testPrepareAddressList
/**
* @param string|Address\AddressInterface|array|AddressList|Traversable $toList
* @param string|Address\AddressInterface|array|AddressList|Traversable $ccList
* @param string|Address\AddressInterface|array|AddressList|Traversable $bccList
* @param array $expectedResult
*
* @covers \EscoMail\Service\MailLogger::prepareAddressList
* @dataProvider provideAddressList
*/
public function testPrepareAddressList($toList, $ccList, $bccList, $expectedResult)
{
$serviceManager = new ServiceManager();
$options = new ModuleOptions();
$mailLogger = new MailLogger($options, $serviceManager);
$message = new Message();
if ($toList !== null) {
$message->setTo($toList);
}
if ($ccList !== null) {
$message->setCc($ccList);
}
if ($bccList !== null) {
$message->setBcc($bccList);
}
$result = $this->invokeMethod($mailLogger, 'prepareAddressList', array($message));
$this->assertEquals($expectedResult, $result);
}