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


PHP Message::getSubject方法代码示例

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


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

示例1: send

 function send($recipients, $type = 'mail')
 {
     global $tikilib, $prefs;
     $logslib = TikiLib::lib('logs');
     $this->mail->getHeaders()->removeHeader('to');
     foreach ((array) $recipients as $to) {
         $this->mail->addTo($to);
     }
     if ($prefs['zend_mail_handler'] == 'smtp' && $prefs['zend_mail_queue'] == 'y') {
         $query = "INSERT INTO `tiki_mail_queue` (message) VALUES (?)";
         $bindvars = array(serialize($this->mail));
         $tikilib->query($query, $bindvars, -1, 0);
         $title = 'mail';
     } else {
         try {
             tiki_send_email($this->mail);
             $title = 'mail';
         } catch (Zend\Mail\Exception\ExceptionInterface $e) {
             $title = 'mail error';
         }
         if ($title == 'mail error' || $prefs['log_mail'] == 'y') {
             foreach ($recipients as $u) {
                 $logslib->add_log($title, $u . '/' . $this->mail->getSubject());
             }
         }
     }
     return $title == 'mail';
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:28,代码来源:tikimaillib.php

示例2: parseSubject

 /**
  * Parse the subject of the email.
  */
 public function parseSubject()
 {
     //Transfer first the subject form the email (if any)
     $this->message->setSubject($this->email->getSubject());
     /*
      * When the subject is empty AND we have a template, simply take the subject of the template
      */
     if (!empty($this->message->getSubject()) && !is_null($this->template)) {
         $this->message->setSubject($this->template->getSubject());
     }
     /*
      * Go over the templateVars to replace content in the subject
      */
     foreach ($this->templateVars as $key => $replace) {
         /*
          * Skip the service manager
          */
         if ($replace instanceof ServiceManager) {
             continue;
         }
         /*
          * replace the content of the title with the available keys in the template vars
          */
         if (!is_array($replace)) {
             $this->message->setSubject(str_replace(sprintf("[%s]", $key), $replace, $this->message->getSubject()));
         }
     }
 }
开发者ID:debranova,项目名称:general,代码行数:31,代码来源:EmailService.php

示例3: send

 /**
  * Send a mail message
  *
  * @param \Zend\Mail\Message $message
  * @return array
  */
 public function send(Mail\Message $message)
 {
     $consumer = new Consumer();
     $consumer->setUrl($this->config['url']);
     $params = array('to' => urlencode($this->config['to']), 'subject' => urlencode($message->getSubject()), 'from' => urlencode($message->getFrom()->current()->getEmail()), 'fromname' => urlencode($message->getFrom()->current()->getName()), 'text' => urlencode($message->getBodyText()), 'api_user' => urlencode($this->config['user']), 'api_key' => urlencode($this->config['key']));
     $bcc = $message->getBcc()->current();
     if ($bcc) {
         $params['bcc'] = $bcc->getEmail();
     }
     $consumer->setParams($params);
     $consumer->setResponseType('json');
     $consumer->setCallType('get');
     return $consumer->doApiCall();
 }
开发者ID:sunshinephp,项目名称:ssp-contact,代码行数:20,代码来源:SspSendGridTransport.php

示例4: send

 /**
  * {@inheritDoc}
  * @link http://help.postageapp.com/kb/api/send_message
  * @throws Exception\RuntimeException if the mail is sent to more than 50 recipients (Amazon SES limit)
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Amazon SES requires exactly one from sender');
     }
     $parameters = array('Source' => $from->rewind()->toString(), 'Message' => array('Subject' => array('Data' => $message->getSubject())));
     $textContent = $this->extractText($message);
     if (!empty($textContent)) {
         $parameters['Message']['Body']['Text']['Data'] = $textContent;
     }
     $htmlContent = $this->extractHtml($message);
     if (!empty($htmlContent)) {
         $parameters['Message']['Body']['Html']['Data'] = $htmlContent;
     }
     $countRecipients = count($message->getTo());
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['Destination']['ToAddresses'] = $to;
     $countRecipients += count($message->getCc());
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['Destination']['CcAddresses'] = $cc;
     $countRecipients += count($message->getBcc());
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['Destination']['BccAddresses'] = $bcc;
     if ($countRecipients > self::RECIPIENT_LIMIT) {
         throw new Exception\RuntimeException(sprintf('You have exceeded limitation for Amazon SES count recipients (%s maximum, %s given)', self::RECIPIENT_LIMIT, $countRecipients));
     }
     $replyTo = array();
     foreach ($message->getReplyTo() as $address) {
         $replyTo[] = $address->toString();
     }
     $parameters['ReplyToAddresses'] = $replyTo;
     try {
         return $this->client->sendEmail($this->filterParameters($parameters))->toArray();
     } catch (SesException $exception) {
         $this->parseException($exception);
     }
 }
开发者ID:misarji,项目名称:ez-mail,代码行数:53,代码来源:SesService.php

示例5: send

 /**
  * {@inheritDoc}
  * @link http://help.postageapp.com/kb/api/send_message
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postage API requires exactly one from sender');
     }
     if (count($message->getCc())) {
         throw new Exception\RuntimeException('Postage does not support CC addresses');
     }
     if (count($message->getBcc())) {
         throw new Exception\RuntimeException('Postage does not support BCC addresses');
     }
     $parameters = array('uid' => sha1(json_encode(uniqid())), 'arguments' => array('headers' => array('subject' => $message->getSubject(), 'from' => $from->rewind()->toString()), 'content' => array('text/plain' => $this->extractText($message), 'text/html' => $this->extractHtml($message))));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['arguments']['recipients'] = implode(',', $to);
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Postage has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['headers']['reply-to'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof PostageMessage) {
         if ($message->getTemplate() !== '') {
             $parameters['arguments']['template'] = $message->getTemplate();
             $parameters['arguments']['variables'] = $message->getVariables();
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['arguments']['attachments'][$attachment->filename] = array('content_type' => $attachment->type, 'content' => base64_encode($attachment->getRawContent()));
     }
     $response = $this->prepareHttpClient('/send_message.json', $parameters)->send();
     $data = $this->parseResponse($response);
     return array('uid' => $parameters['uid'], 'id' => $data['message']['id']);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:43,代码来源:PostageService.php

示例6: send

 /**
  * {@inheritDoc}
  * @link   http://elasticemail.com/api-documentation/send
  * @return string The transaction id of the email
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Elastic Email API requires exactly one from sender');
     }
     $parameters = array('from' => $from->rewind()->getEmail(), 'from_name' => $from->rewind()->getName(), 'subject' => $message->getSubject(), 'body_text' => $this->extractText($message), 'body_html' => $this->extractHtml($message));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     foreach ($message->getCc() as $address) {
         $to[] = $address->toString();
     }
     // Elastic Email treats Bcc exactly as To addresses (they are treated separately)
     foreach ($message->getBcc() as $address) {
         $to[] = $address->toString();
     }
     $parameters['to'] = implode(';', $to);
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Elastic Email has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['reply_to'] = $replyTo->rewind()->getEmail();
         $parameters['reply_to_name'] = $replyTo->rewind()->getName();
     }
     if ($message instanceof ElasticEmailMessage) {
         $parameters['channel'] = $message->getChannel();
         $parameters['template'] = $message->getTemplate();
     }
     // Attachments are handled using a very strange way in Elastic Email. They must first be uploaded
     // to their API and THEN appended here. Therefore, you should limit how many attachments you have
     $attachmentIds = array();
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $attachmentIds[] = $this->uploadAttachment($attachment);
     }
     if (count($attachmentIds)) {
         $parameters['attachments'] = implode(';', $attachmentIds);
     }
     $response = $this->prepareHttpClient('/mailer/send', $parameters)->send();
     return $this->parseResponse($response);
 }
开发者ID:misarji,项目名称:ez-mail,代码行数:48,代码来源:ElasticEmailService.php

示例7: send

 /**
  * {@inheritDoc}
  * @link http://developer.postmarkapp.com/developer-build.html
  * @throws Exception\RuntimeException if the mail is sent to more than 20 recipients (Postmark limit)
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postmark API requires exactly one from sender');
     }
     $parameters = array('From' => $from->rewind()->toString(), 'Subject' => $message->getSubject(), 'TextBody' => $this->extractText($message), 'HtmlBody' => $this->extractHtml($message));
     $countRecipients = count($message->getTo());
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['To'] = implode(',', $to);
     $countRecipients += count($message->getCc());
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['Cc'] = implode(',', $cc);
     $countRecipients += count($message->getBcc());
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['Bcc'] = implode(',', $bcc);
     if ($countRecipients > self::RECIPIENT_LIMIT) {
         throw new Exception\RuntimeException(sprintf('You have exceeded limitation for Postmark count recipients (%s maximum, %s given)', self::RECIPIENT_LIMIT, $countRecipients));
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Postmark has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['ReplyTo'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof PostmarkMessage) {
         if ($message->getTag()) {
             $parameters['Tag'] = $message->getTag();
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['Attachments'][] = array('Name' => $attachment->filename, 'ContentType' => $attachment->type, 'Content' => base64_encode($attachment->getRawContent()));
     }
     $response = $this->prepareHttpClient('/email')->setMethod(HttpRequest::METHOD_POST)->setRawBody(json_encode($this->filterParameters($parameters)))->send();
     return $this->parseResponse($response);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:52,代码来源:PostmarkService.php

示例8: prepareSubject

 /**
  * Prepare the subject line string
  * 
  * @param  Message $message 
  * @return string
  */
 protected function prepareSubject(Message $message)
 {
     return $message->getSubject();
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:10,代码来源:Sendmail.php

示例9: testSubjectIsMutable

 public function testSubjectIsMutable()
 {
     $this->message->setSubject('test subject');
     $subject = $this->message->getSubject();
     $this->assertEquals('test subject', $subject);
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:6,代码来源:MessageTest.php

示例10: parseMessage

 /**
  * @param  Message       $message
  * @param  DateTime|null $sendAt
  * @throws Exception\RuntimeException
  * @return array
  */
 private function parseMessage(Message $message, DateTime $sendAt = null)
 {
     $hasTemplate = $message instanceof MandrillMessage && null !== $message->getTemplate();
     $from = $message->getFrom();
     if ($hasTemplate && count($from) > 1 || !$hasTemplate && count($from) !== 1) {
         throw new Exception\RuntimeException('Mandrill API requires exactly one from sender (or none if send with a template)');
     }
     $from = $from->rewind();
     $parameters['message'] = array('subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message), 'from_email' => $from ? $from->getEmail() : '', 'from_name' => $from ? $from->getName() : '');
     foreach ($message->getTo() as $to) {
         $parameters['message']['to'][] = array('email' => $to->getEmail(), 'name' => $to->getName(), 'type' => 'to');
     }
     foreach ($message->getCc() as $cc) {
         $parameters['message']['to'][] = array('email' => $cc->getEmail(), 'name' => $cc->getName(), 'type' => 'cc');
     }
     foreach ($message->getBcc() as $bcc) {
         $parameters['message']['to'][] = array('email' => $bcc->getEmail(), 'name' => $bcc->getName(), 'type' => 'bcc');
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Mandrill has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['message']['headers']['Reply-To'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof MandrillMessage) {
         if ($hasTemplate) {
             $parameters['template_name'] = $message->getTemplate();
             foreach ($message->getTemplateContent() as $key => $value) {
                 $parameters['template_content'][] = array('name' => $key, 'content' => $value);
             }
             // Currently, Mandrill API requires a content for template_content, even if it is an
             // empty array
             if (!isset($parameters['template_content'])) {
                 $parameters['template_content'] = array();
             }
         }
         foreach ($message->getGlobalVariables() as $key => $value) {
             $parameters['message']['global_merge_vars'][] = array('name' => $key, 'content' => $value);
         }
         foreach ($message->getVariables() as $recipient => $variables) {
             $recipientVariables = array();
             foreach ($variables as $key => $value) {
                 $recipientVariables[] = array('name' => $key, 'content' => $value);
             }
             $parameters['message']['merge_vars'][] = array('rcpt' => $recipient, 'vars' => $recipientVariables);
         }
         $parameters['message']['metadata'] = $message->getGlobalMetadata();
         foreach ($message->getMetadata() as $recipient => $variables) {
             $parameters['message']['recipient_metadata'][] = array('rcpt' => $recipient, 'values' => $variables);
         }
         foreach ($message->getOptions() as $key => $value) {
             $parameters['message'][$key] = $value;
         }
         foreach ($message->getTags() as $tag) {
             $parameters['message']['tags'][] = $tag;
         }
         foreach ($message->getImages() as $image) {
             $parameters['message']['images'][] = array('type' => $image->type, 'name' => $image->filename, 'content' => base64_encode($image->getRawContent()));
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['message']['attachments'][] = array('type' => $attachment->type, 'name' => $attachment->filename, 'content' => base64_encode($attachment->getRawContent()));
     }
     if (null !== $sendAt) {
         // Mandrill needs to have date in UTC, using this format
         $sendAt->setTimezone(new DateTimeZone('UTC'));
         $parameters['send_at'] = $sendAt->format('Y-m-d H:i:s');
     }
     return $parameters;
 }
开发者ID:roelvanduijnhoven,项目名称:SlmMail,代码行数:77,代码来源:MandrillService.php

示例11: testMessageReturnsNonEncodedSubject

 public function testMessageReturnsNonEncodedSubject()
 {
     $this->message->setSubject('This is a subject');
     $this->message->setEncoding('UTF-8');
     $this->assertEquals('This is a subject', $this->message->getSubject());
 }
开发者ID:nieldm,项目名称:zf2,代码行数:6,代码来源:MessageTest.php

示例12: send

 /**
  * @param Message $message
  * @return bool
  */
 public function send(Message $message)
 {
     $this->email->addTo($message->getTo()->current()->getEmail(), $message->getTo()->current()->getName())->setFrom($message->getFrom()->current()->getEmail(), $message->getFrom()->current()->getName())->setSubject($message->getSubject())->setHtml($message->getBodyText());
     $this->sendGrid->send($this->email);
     return true;
 }
开发者ID:andrebian,项目名称:sendgrid-transport-module,代码行数:10,代码来源:SendGridTransport.php

示例13: dontSeeInEmailSubject

 /**
  * Don't See In Subject
  *
  * Look for the absence of a string in an email subject
  *
  * @return void
  * @author Koen Punt
  **/
 protected function dontSeeInEmailSubject(Message $email, $unexpected)
 {
     $this->assertNotContains($unexpected, $email->getSubject(), "Email Subject Does Not Contain");
 }
开发者ID:fetch,项目名称:zend-mail-codeception-module,代码行数:12,代码来源:ZendMail.php

示例14: send

 /**
  * {@inheritDoc}
  * @link http://sendgrid.com/docs/API_Reference/Web_API/mail.html
  * @return mixed
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('SendGrid API requires exactly one from sender');
     }
     if (count($message->getCc())) {
         throw new Exception\RuntimeException('SendGrid does not support CC addresses');
     }
     $parameters = array('from' => $from->rewind()->getEmail(), 'fromname' => $from->rewind()->getName(), 'subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message));
     foreach ($message->getTo() as $address) {
         $parameters['to'][] = $address->getEmail();
     }
     foreach ($message->getBcc() as $address) {
         $parameters['bcc'][] = $address->getEmail();
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('SendGrid has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['replyto'] = $replyTo->rewind()->getEmail();
     }
     $client = $this->prepareHttpClient('/mail.send.json');
     // Set Parameters as POST, since prepareHttpClient() put only GET parameters
     $client->setParameterPost($parameters);
     // Eventually add files. This cannot be done before prepareHttpClient call because prepareHttpClient
     // reset all parameters (response, request...), therefore we would loose the file upload
     $post = $client->getRequest()->getPost();
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $post->set('files[' . $attachment->filename . ']', $attachment->getRawContent());
     }
     $response = $client->setMethod(HttpRequest::METHOD_POST)->setEncType(HttpClient::ENC_FORMDATA)->send();
     return $this->parseResponse($response);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:40,代码来源:SendGridService.php

示例15: send

 /**
  * {@inheritDoc}
  * @link http://documentation.mailgun.com/api-sending.html
  * @return string id of message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postage API requires exactly one from sender');
     }
     $parameters = array('from' => $from->rewind()->toString(), 'subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['to'] = implode(',', $to);
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['cc'] = implode(',', $cc);
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['bcc'] = implode(',', $bcc);
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['attachment'][] = $attachment->filename;
     }
     if ($message instanceof MailgunMessage) {
         $options = $message->getValidOptions();
         foreach ($message->getOptions() as $key => $value) {
             $parameters[$options[$key]] = $value;
         }
         $tags = $message->getTags();
         if (count($tags) > 0) {
             $parameters['o:tag'] = $tags;
         }
         $variables = $message->getRecipientVariables();
         if (count($variables)) {
             // It is only possible to add variables for recipients that exist in the To: field
             foreach ($variables as $recipient => $variable) {
                 if (!$message->getTo()->has($recipient)) {
                     throw new Exception\RuntimeException(sprintf('The email "%s" must be added as a receiver before you can add recipient variables', $recipient));
                 }
             }
             $parameters['recipient-variables'] = json_encode($variables);
         }
     }
     $client = $this->prepareHttpClient('/messages', $parameters);
     // Eventually add files. This cannot be done before prepareHttpClient call because prepareHttpClient
     // reset all parameters (response, request...), therefore we would loose the file upload
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $client->setFileUpload($attachment->filename, 'attachment', $attachment->getRawContent(), $attachment->type);
     }
     $client->setEncType(HttpClient::ENC_FORMDATA);
     $response = $client->send();
     $result = $this->parseResponse($response);
     return $result['id'];
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:63,代码来源:MailgunService.php


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