예제 #1
0
 protected function processPart(Email\Part $part)
 {
     if (!$part instanceof Email\TwigTemplatePart) {
         return;
     }
     $part->setContent($this->twig->render($part->getTemplateName(), $part->getVars()));
 }
예제 #2
0
 private function getEncoder(Email\Part $part)
 {
     $encoding = $part->getEncoding();
     if (null === $encoding) {
         return null;
     }
     switch ($encoding) {
         case Email::ENCODING_BASE64:
             return \Swift_Encoding::getBase64Encoding();
         case Email::ENCODING_QUOTED_PRINTABLE:
             return \Swift_Encoding::getQpEncoding();
         case Email::ENCODING_8BIT:
             return \Swift_Encoding::get8BitEncoding();
         case Email::ENCODING_7BIT:
             return \Swift_Encoding::get7BitEncoding();
         case Email::ENCODING_RAW:
             return new \Swift_Mime_ContentEncoder_RawContentEncoder();
         default:
             throw new \InvalidArgumentException('Unknown encoding "' . $encoding . '"');
     }
 }
예제 #3
0
파일: Email.php 프로젝트: fazland/notifire
 /**
  * Add or replace the plain text part of the mail
  *
  * @param $text
  *
  * @return Email
  */
 public function setText($text)
 {
     return $this->addPart(Part::create($text, 'text/plain'), true);
 }
예제 #4
0
 public function testShouldSetMultipartAlternativeIfEmailIsMultipart()
 {
     $email = new Email();
     $email->addPart(Email\Part::create('BODY PART', 'text/plain'))->addPart(Email\Part::create('PART 2', 'text/html'));
     $this->mailer->send(Argument::that(function ($argument) {
         if (!$argument instanceof \Swift_Message) {
             return false;
         }
         $this->assertCount(2, $argument->getChildren());
         $this->assertEquals('multipart/alternative', $argument->getContentType());
         return true;
     }))->willReturn(1);
     $this->handler->notify($email);
 }
예제 #5
0
 /**
  * @expectedException \Fazland\Notifire\Exception\PartContentTypeMismatchException
  */
 public function testAddPartShouldThrowIfTwoPartsWithSameContentTypeHasAdded()
 {
     Email::create()->addPart(Email\Part::create('BlaBla', 'text/html'))->addPart(Email\Part::create('Foo bar', 'text/html'));
 }