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


PHP Email::getSubject方法代码示例

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


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

示例1: addMailToSend

 /**
  *
  * Mauro Cerone
  *
  * @param Email $email        	
  * @todo implement the attachment (path to file, or database blob)
  */
 public static function addMailToSend(Email $email)
 {
     if (!empty($email->getStringA())) {
         $newMail = new StesiMail();
         $newMail->setFrom($email->getFrom()->getAddress())->setA($email->getStringA())->setCc($email->getStringCc())->setContent($email->getTemplate()->getHtml())->setSubject($email->getSubject());
         $newMail->save();
     }
 }
开发者ID:stesi,项目名称:mail-dispatcher,代码行数:15,代码来源:Mailer.php

示例2: testSetSubject

 /**
  * Tests the `setSubject` method.
  *
  * @return void
  * @access public
  */
 public function testSetSubject()
 {
     $this->assertIdentical($this->_object->getSubject(), '');
     // Make sure the setting was successful.
     $this->_object->setSubject('Test');
     $this->assertIdentical($this->_object->getSubject(), 'Test');
     // We only allow strings to be passed in.
     $this->expectException();
     $this->_object->setSubject(new Object());
 }
开发者ID:joebeeson,项目名称:mailer,代码行数:16,代码来源:Email.test.php

示例3: queryToEmail

 /**
  * Performs a Google Analytics query with the given Google\Analytics\IQuery
  * object and attaches the result to the given Email instance. If the email
  * does not yet have a subject, one will be set automatically. If failures
  * took place while running the query (e.g. the query declared a preference
  * for no data sampling and one or more iterations contained sampled data),
  * a message regarding the failure will be appended to the email
  * automatically. If a file path is provided as the fourth argument, the
  * report will be copied to that location in addition to being attached to
  * the email.
  *
  * @param Google\Analytics\IQuery $query
  * @param Google\Analytics\ReportFormatter $formatter
  * @param Email $email
  * @param string $file = null
  */
 public function queryToEmail(IQuery $query, ReportFormatter $formatter, \Email $email, $file = null)
 {
     if ($file && !\PFXUtils::testWritable(dirname($file))) {
         throw new RuntimeException('Cannot write to ' . $file . '.');
     }
     $hasSubject = strlen($email->getSubject()) > 0;
     try {
         $formatter->openTempFile(GOOGLE_ANALYTICS_API_DATA_DIR);
         $exception = null;
         try {
             $this->queryToFile($query, $formatter);
         } catch (FailedIterationsException $e) {
             /* Trap this exception here for now and deliver whatever data
                we can. */
             $exception = $e;
         }
         $bytesWritten = $formatter->getBytesWritten();
         if ($bytesWritten) {
             $tempFile = $formatter->getFileName();
             if ($bytesWritten > GOOGLE_ANALYTICS_API_AUTOZIP_THRESHOLD) {
                 $zip = new \ZipArchive();
                 $tempZip = tempnam(GOOGLE_ANALYTICS_API_DATA_DIR, 'gaz');
                 if ($zip->open($tempZip, \ZipArchive::CREATE) !== true) {
                     throw new RuntimeException('Failed to initialize ZIP archive. Did not ' . 'include the file ' . basename($tempFile) . ' in this message due to its size exceeding ' . GOOGLE_ANALYTICS_API_AUTOZIP_THRESHOLD . ' bytes.');
                 }
                 $zip->addFile($tempFile, 'ga-report.csv');
                 $zip->close();
                 $email->addAttachment($tempZip, 'ga-report.zip');
                 unlink($tempZip);
             } else {
                 $email->addAttachment($tempFile, 'ga-report.csv');
             }
             if ($file && !copy($tempFile, $file)) {
                 throw new RuntimeException('Unable to copy report to ' . $file . '.');
             }
             unlink($tempFile);
         }
         if (!$hasSubject) {
             $email->setSubject($query->getEmailSubject());
             $hasSubject = true;
         }
         if ($exception) {
             throw $exception;
         } elseif (!$bytesWritten) {
             throw new UnderflowException('Google returned no data for this query.');
         }
     } catch (\Exception $e) {
         if (!$hasSubject) {
             /* This should only happen if there is an error affecting the
                report as a whole, not just in one or more of its iterations.
                */
             $email->setSubject('Encountered failure while running ' . $query->getEmailSubject());
         }
         $email->appendMessage($e->getMessage(), true);
     }
 }
开发者ID:performics,项目名称:ga-cli-api,代码行数:72,代码来源:API.class.php

示例4: test

 /**
  * Runs the test.
  */
 public function test()
 {
     $filePath = DIR_FILES . '/mail';
     $subject = 'Novinky září 2009 ... a kreslící soutěž';
     $from = new Email\Address('blog-noreply@blog.cz', 'Blog.cz');
     $to = array(new Email\Address('test1@blog.cz', 'Test Test1'), new Email\Address('test2@blog.cz'));
     $cc = array(new Email\Address('test3@blog.cz', 'Test Test3'), new Email\Address('test4@blog.cz'));
     $bcc = array(new Email\Address('test5@blog.cz', 'Test Test5'));
     $headers = array(new Email\Header('Organization', 'Blog.cz'));
     $inReplyTo = '161024ac03484c10203285be576446f2@blog.cz';
     $references = array('30d6c4933818e36fa46509ad24a91ea4@blog.cz', '8b30935de59b6c89e4fc1204d279a2af@blog.cz');
     $html = file_get_contents($filePath . '/email.html');
     $body = new Email\Body($html, \Jyxo\Html::toText($html));
     $attachments = array(new Email\Attachment\File($filePath . '/logo.gif', 'logo.gif', 'image/gif'), new Email\Attachment\String(file_get_contents($filePath . '/star.gif'), 'star.gif', 'image/gif'));
     $inlineAttachments = array(new Email\Attachment\InlineFile($filePath . '/logo.gif', 'logo.gif', 'logo.gif', 'image/gif'), new Email\Attachment\InlineString(file_get_contents($filePath . '/star.gif'), 'star.gif', 'star.gif', 'image/gif'));
     // Basic settings
     $email = new Email();
     $email->setSubject($subject)->setFrom($from)->addReplyTo($from)->setInReplyTo($inReplyTo, $references)->setConfirmReadingTo($from);
     $this->assertEquals($subject, $email->getSubject());
     $this->assertSame($from, $email->getFrom());
     $this->assertSame(array($from), $email->getReplyTo());
     $this->assertSame($from, $email->getConfirmReadingTo());
     $this->assertEquals($inReplyTo, $email->getInReplyTo());
     $this->assertSame($references, $email->getReferences());
     // Recipients
     foreach ($to as $address) {
         $email->addTo($address);
     }
     foreach ($cc as $address) {
         $email->addCc($address);
     }
     foreach ($bcc as $address) {
         $email->addBcc($address);
     }
     $this->assertSame($to, $email->getTo());
     $this->assertSame($cc, $email->getCc());
     $this->assertSame($bcc, $email->getBcc());
     // Priority
     $reflection = new \ReflectionClass('\\Jyxo\\Mail\\Email');
     foreach ($reflection->getConstants() as $name => $value) {
         if (0 === strpos($name, 'PRIORITY_')) {
             $email->setPriority($value);
             $this->assertEquals($value, $email->getPriority());
         }
     }
     try {
         $email->setPriority('dummy-priority');
         $this->fail('Expected exception \\InvalidArgumentException.');
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf('\\InvalidArgumentException', $e);
     }
     // Headers
     foreach ($headers as $header) {
         $email->addHeader($header);
     }
     $this->assertSame($headers, $email->getHeaders());
     // Body
     $email->setBody($body);
     $this->assertSame($body, $email->getBody());
     // Attachments
     foreach ($attachments as $attachment) {
         $email->addAttachment($attachment);
     }
     $this->assertSame($attachments, $email->getAttachments());
     $this->assertFalse($email->hasInlineAttachments());
     foreach ($inlineAttachments as $attachment) {
         $email->addAttachment($attachment);
     }
     $this->assertSame(array_merge($attachments, $inlineAttachments), $email->getAttachments());
     $this->assertTrue($email->hasInlineAttachments());
 }
开发者ID:JerryCR,项目名称:php-2,代码行数:77,代码来源:EmailTest.php

示例5: testConstructSubject

 /**
  *
  */
 public function testConstructSubject()
 {
     $email = new Email('jon@walleye.com', 'subject', 'hello you');
     $this->assertEquals('subject', $email->getSubject());
 }
开发者ID:Jmayhak,项目名称:Walleye,代码行数:8,代码来源:EmailTest.php

示例6: Email

 function test_setSubject()
 {
     //Arrange
     $name = "Bill";
     $email = "bill@gmail.com";
     $subject = "Just saying hi";
     $message = "Hello to you good sir";
     $notarobot = "123";
     $test_email = new Email($name, $email, $subject, $message, $notarobot);
     //Act
     $new_subject = "Just saying hi, again";
     $test_email->setSubject($new_subject);
     $result = $test_email->getSubject();
     //Assert
     $this->assertEquals("Just saying hi, again", $result);
 }
开发者ID:bjkropff,项目名称:send_email,代码行数:16,代码来源:EmailTest.php

示例7: sendEmail

 public function sendEmail(Email $email)
 {
     mail($email->getRecipientList(), $email->getSubject(), $email->getBodyRaw(), $email->getMailHeadersAsString());
 }
开发者ID:robertfalconer,项目名称:Rhubarb,代码行数:4,代码来源:PhpMailEmailProvider.php

示例8: _mapToSwift

 protected function _mapToSwift(Email $email)
 {
     $message = new \Swift_Message($email->getSubject());
     /*
      * Since we're sending transactional email, we want the message to go to one person at a time, rather
      * than a bulk send on one message. In order to do this, we'll have to send the list of recipients through the headers
      * but Swift still requires a 'to' address. So we'll falsify it with the from address, as it will be 
      * ignored anyway.
      */
     $message->setTo($email->getFrom());
     $message->setFrom($email->getFrom(true));
     $message->setCc($email->getCcs());
     $message->setBcc($email->getBccs());
     if ($email->getHtml()) {
         $message->setBody($email->getHtml(), 'text/html');
         if ($email->getText()) {
             $message->addPart($email->getText(), 'text/plain');
         }
     } else {
         $message->setBody($email->getText(), 'text/plain');
     }
     if ($replyto = $email->getReplyTo()) {
         $message->setReplyTo($replyto);
     }
     // determine whether or not we can use SMTP recipients (non header based)
     if ($email->useHeaders()) {
         //send header based email
         $message->setTo($email->getFrom());
         //here we'll add the recipients list to the headers
         $headers = $email->getSmtpapiHeaders();
         $headers['to'] = $email->getTos();
         $email->setSmtpapiHeaders($headers);
     } else {
         $recipients = array();
         foreach ($email->getTos() as $recipient) {
             if (preg_match("/(.*)<(.*)>/", $recipient, $results)) {
                 $recipients[trim($results[2])] = trim($results[1]);
             } else {
                 $recipients[] = $recipient;
             }
         }
         $message->setTo($recipients);
     }
     $attachments = $email->getAttachments();
     //add any attachments that were added
     if ($attachments) {
         foreach ($attachments as $attachment) {
             if (array_key_exists('custom_filename', $attachment)) {
                 $message->attach(\Swift_Attachment::fromPath($attachment['file'])->setFileName($attachment['custom_filename']));
             } else {
                 $message->attach(\Swift_Attachment::fromPath($attachment['file']));
             }
         }
     }
     //add all the headers
     $headers = $message->getHeaders();
     $headers->addTextHeader('X-SMTPAPI', $email->getSmtpapiHeadersJson());
     // Add the extra message headers (RFC 822)
     if (count($email->getMessageHeaders())) {
         foreach ($email->getMessageHeaders() as $name => $value) {
             $headers->addTextHeader($name, $value);
         }
     }
     return $message;
 }
开发者ID:tony13tv,项目名称:silverstripe-sendgrid-integration,代码行数:65,代码来源:Smtp.php


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