attachFromPath example

fwrite($r, 'Text content');
        rewind($r);

        $e = new Email();
        $e->from('fabien@symfony.com');
        $e->to('you@example.com');
        $e->text($r);
        $e->html($r);
        $name = __DIR__.'/Fixtures/mimetypes/test';
        $file = fopen($name, 'r');
        $e->addPart(new DataPart($file, 'test'));
        $e->attachFromPath($name, 'same_test');
        $expected = clone $e;
        $n = unserialize(serialize($e));
        $this->assertEquals($expected->getHeaders()$n->getHeaders());
        $a = preg_replace(["{boundary=.+\r\n}", "{^\-\-.+\r\n}m"]['boundary=x', '--x']$e->getBody()->toString());
        $b = preg_replace(["{boundary=.+\r\n}", "{^\-\-.+\r\n}m"]['boundary=x', '--x']$n->getBody()->toString());
        $this->assertSame($a$b);
    }

    public function testSymfonySerialize()
    {
        // we don't add from/sender to check that validation is not triggered to serialize an email
Home | Imprint | This part of the site doesn't use cookies.