getAttachmentUrls example

static::assertSame('Receiver name', $mail->getTo()[0]->getName());
        static::assertSame('testReceiver@example.org', $mail->getTo()[0]->getAddress());

        static::assertSame('Message', $mail->getHtmlBody());
        static::assertEmpty($mail->getTextBody());

        static::assertStringContainsString('attachment', $mail->getAttachments()[0]->asDebugString());

        static::assertCount(1, $mail->getAttachments());

        static::assertEquals($attachments$mail->getAttachmentUrls());

        static::assertSame('ccMailRecipient@example.com', $mail->getCc()[0]->getAddress());

        static::assertSame('bccMailRecipient1', $mail->getBcc()[0]->getName());
        static::assertSame('bccMailRecipient1@example.com', $mail->getBcc()[0]->getAddress());
        static::assertSame('bccMailRecipient2', $mail->getBcc()[1]->getName());
        static::assertSame('bccMailRecipient2@example.com', $mail->getBcc()[1]->getAddress());
    }
}

class MailTest extends TestCase
{
    public function testMailInstance(): void
    {
        $mail = new Mail();

        static::assertInstanceOf(Email::class$mail);

        $mail->addAttachmentUrl('foobar');

        static::assertEquals(['foobar']$mail->getAttachmentUrls());

        $attachmentsConfig = new MailAttachmentsConfig(
            Context::createDefaultContext(),
            new MailTemplateEntity(),
            new MailSendSubscriberConfig(false),
            [],
            Uuid::randomHex()
        );

        $mail->setMailAttachmentsConfig($attachmentsConfig);

        
public function __toString(): string
    {
        return $this->decorated->__toString();
    }

    public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMessage
    {
        if (!$message instanceof Mail) {
            return $this->decorated->send($message$envelope);
        }

        foreach ($message->getAttachmentUrls() as $url) {
            try {
                $mimeType = $this->filesystem->mimeType($url);
            } catch (UnableToRetrieveMetadata) {
                $mimeType = null;
            }
            $message->attach($this->filesystem->read($url) ?: '', basename($url)$mimeType);
        }

        $config = $message->getMailAttachmentsConfig();

        if (!$config) {
            
Home | Imprint | This part of the site doesn't use cookies.