cc example



    public function testSendFullEmailShouldCalledInfobipWithTheRightParameters()
    {
        $email = (new Email())
            ->subject('Subject of the email')
            ->from('From <from@example.com>')
            ->to('to1@example.com', 'to2@example.com')
            ->text('Some text')
            ->html('<html><p>Hello!</p></html>')
            ->bcc('bcc@example.com')
            ->cc('cc@example.com')
            ->date(new \DateTimeImmutable('2022-04-28 14:00.00', new \DateTimeZone('UTC')))
            ->replyTo('replyTo@example.com')
        ;

        $this->transport->send($email);

        $options = $this->response->getRequestOptions();
        $this->arrayHasKey('body');
        $this->assertStringMatchesFormat(<<<'TXT' --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="from" "From" <from@example.com> --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="subject" Subject of the email --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="to" to1@example.com --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="to" to2@example.com --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="cc" cc@example.com --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="bcc" bcc@example.com --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="replyto" replyTo@example.com --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="text" Some text --%s Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="HTML" <html><p>Hello!</p></html> --%s--
$e->to($caramel);
        $this->assertSame([$caramel]$e->getTo());
    }

    public function testCc()
    {
        $e = new Email();
        $helene = new Address('helene@symfony.com');
        $thomas = new Address('thomas@symfony.com', 'Thomas');
        $caramel = new Address('caramel@symfony.com');

        $this->assertSame($e$e->cc('fabien@symfony.com', $helene$thomas));
        $v = $e->getCc();
        $this->assertCount(3, $v);
        $this->assertEquals(new Address('fabien@symfony.com')$v[0]);
        $this->assertSame($helene$v[1]);
        $this->assertSame($thomas$v[2]);

        $this->assertSame($e$e->addCc('lucas@symfony.com', $caramel));
        $v = $e->getCc();
        $this->assertCount(5, $v);
        $this->assertEquals(new Address('fabien@symfony.com')$v[0]);
        $this->assertSame($helene$v[1]);
        
return new MockResponse($json[
                'http_code' => 200,
            ]);
        });

        $transport = new SesApiAsyncAwsTransport(new SesClient(Configuration::create([])new NullProvider()$client));

        $mail = new Email();
        $mail->subject('Hello!')
            ->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
            ->cc(new Address('jeremy@derusse.com', 'Jérémy'))
            ->from(new Address('fabpot@symfony.com', 'Fabién'))
            ->text('Hello There!')
            ->html('<b>Hello There!</b>')
            ->replyTo(new Address('replyto-1@example.com')new Address('replyto-2@example.com'))
            ->returnPath(new Address('bounces@example.com'));

        $mail->getHeaders()->addTextHeader('X-SES-CONFIGURATION-SET', 'aws-configuration-set-name');
        $mail->getHeaders()->addTextHeader('X-SES-SOURCE-ARN', 'aws-source-arn');
        $mail->getHeaders()->add(new MetadataHeader('tagName1', 'tag Value1'));
        $mail->getHeaders()->add(new MetadataHeader('tagName2', 'tag Value2'));

        


    public function testEnvelopeSenderAndRecipients()
    {
        $from = 'from@example.com';
        $to = 'to@example.com';
        $envelopeFrom = 'envelopefrom@example.com';
        $envelopeTo = 'envelopeto@example.com';
        $email = new Email();
        $email->from($from)
            ->to($to)
            ->cc('cc@example.com')
            ->bcc('bcc@example.com')
            ->text('content');
        $envelope = new Envelope(new Address($envelopeFrom)[new Address($envelopeTo)]);

        $transport = new SendgridApiTransport('ACCESS_KEY');
        $method = new \ReflectionMethod(SendgridApiTransport::class, 'getPayload');
        $payload = $method->invoke($transport$email$envelope);

        $this->assertArrayHasKey('from', $payload);
        $this->assertArrayHasKey('email', $payload['from']);
        $this->assertSame($envelopeFrom$payload['from']['email']);

        
Home | Imprint | This part of the site doesn't use cookies.