PHP code example of flowmailer / symfony-flowmailer-mailer

1. Go to this page and download the library: Download flowmailer/symfony-flowmailer-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/ */

    

flowmailer / symfony-flowmailer-mailer example snippets


use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;
use Flowmailer\Symfony\Mailer\Transport\FlowmailerTransportFactory;

$factory   = new FlowmailerTransportFactory();
$transport = new Transport([$factory]);
$mailer    = new Mailer($transport->fromString($dsnString));

$email = (new Email())
    ->from('[email protected]')
    ->to('[email protected]')
    ->subject('Test e-mail')
    ->text('This is the content of the email')
    ->html('<p>Test e-mail with inline image</p><img src="cid:inline-image">')
    ->attachFromPath('path/to/attachment.pdf')
    ->embedFromPath('path/to/inline-image.png', 'inline-image')
;

$mailer->send($email);