IdentificationHeader example


    public function addMailboxHeader(string $name, Address|string $address)static
    {
        return $this->add(new MailboxHeader($name, Address::create($address)));
    }

    /** * @return $this */
    public function addIdHeader(string $name, string|array $ids)static
    {
        return $this->add(new IdentificationHeader($name$ids));
    }

    /** * @return $this */
    public function addPathHeader(string $name, Address|string $path)static
    {
        return $this->add(new PathHeader($name$path instanceof Address ? $path : new Address($path)));
    }

    /** * @return $this */


    public function testAsInlineWithCID()
    {
        $p = new DataPart('content', 'photo.jpg', 'text/html');
        $p->asInline();
        $cid = $p->getContentId();
        $this->assertEquals(new Headers(
            new ParameterizedHeader('Content-Type', 'text/html', ['name' => 'photo.jpg']),
            new UnstructuredHeader('Content-Transfer-Encoding', 'base64'),
            new ParameterizedHeader('Content-Disposition', 'inline', ['name' => 'photo.jpg', 'filename' => 'photo.jpg']),
            new IdentificationHeader('Content-ID', $cid)
        )$p->getPreparedHeaders());
    }

    public function testFromPath()
    {
        $p = DataPart::fromPath($file = __DIR__.'/../Fixtures/mimetypes/test.gif');
        $content = file_get_contents($file);
        $this->assertEquals($content$p->getBody());
        $this->assertEquals(base64_encode($content)$p->bodyToString());
        $this->assertEquals(base64_encode($content)implode('', iterator_to_array($p->bodyToIterable())));
        $this->assertEquals('image', $p->getMediaType());
        

    public function addMailboxHeader(string $name, Address|string $address)static
    {
        return $this->add(new MailboxHeader($name, Address::create($address)));
    }

    /** * @return $this */
    public function addIdHeader(string $name, string|array $ids)static
    {
        return $this->add(new IdentificationHeader($name$ids));
    }

    /** * @return $this */
    public function addPathHeader(string $name, Address|string $path)static
    {
        return $this->add(new PathHeader($name$path instanceof Address ? $path : new Address($path)));
    }

    /** * @return $this */
public function testHasCanDistinguishMultipleHeaders()
    {
        $headers = new Headers();
        $headers->addTextHeader('X-Test', 'some@id');
        $headers->addTextHeader('X-Test', 'other@id');
        $this->assertTrue($headers->has('X-Test'));
    }

    public function testGet()
    {
        $header = new IdentificationHeader('Message-ID', 'some@id');
        $headers = new Headers();
        $headers->addIdHeader('Message-ID', 'some@id');
        $this->assertEquals($header->toString()$headers->get('Message-ID')->toString());
    }

    public function testGetReturnsNullIfHeaderNotSet()
    {
        $headers = new Headers();
        $this->assertNull($headers->get('Message-ID'));
    }

    


        $header = new IdentificationHeader('Message-ID', 'id-left@id-right');
        $this->assertEquals('<id-left@id-right>', $header->getBodyAsString());
    }

    public function testIdCanBeRetrievedVerbatim()
    {
        $header = new IdentificationHeader('Message-ID', 'id-left@id-right');
        $this->assertEquals('id-left@id-right', $header->getId());
    }

    public function testMultipleIdsCanBeSet()
    {
        
Home | Imprint | This part of the site doesn't use cookies.