PHP code example of duva-mail / symfony-mailer

1. Go to this page and download the library: Download duva-mail/symfony-mailer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

duva-mail / symfony-mailer example snippets


// config/bundles.php
return [
    // ...
    Duva\Symfony\Mailer\DuvaMailerBundle::class => ['all' => true],
];

use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;

$email = (new Email())->from('Shop <[email protected]>')->to('[email protected]')->subject('Order')->html('<p>Thanks</p>');
$email->getHeaders()->add(new TagHeader('order'));
$email->getHeaders()->add(new MetadataHeader('order_id', '42'));
$email->getHeaders()->addTextHeader('X-Idempotency-Key', 'order-42'); // see "Idempotency"
$mailer->send($email);

$factory = new DuvaTransportFactory();
$factory->httpTransport = new TestTransport(fn () => TestTransport::response(['id' => 'msg_...', 'status' => 'queued']));