PHP code example of sendery / symfony

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

    

sendery / symfony example snippets


use Sendery\Symfony\TemplateEmail;
use Symfony\Component\Mailer\MailerInterface;

final class TemplateEmails
{
    public function __construct(private MailerInterface $mailer) {}

    public function send(string $address, string $template, array $data): void
    {
        $email = (new TemplateEmail())
            ->from('[email protected]')
            ->to($address)
            ->template($template, $data);

        $this->mailer->send($email);
    }
}

use Sendery\Symfony\TemplateEmail;

$email = (new TemplateEmail())
    ->from('[email protected]')
    ->to('[email protected]')
    ->template('your-template', [
        'name' => 'Alex',
        'action_url' => 'https://example.com/start',
    ])
    ->version(3);

$mailer->send($email);

use Sendery\Symfony\TemplateEmail;

$email = (new TemplateEmail())
    ->from('[email protected]')
    ->to('[email protected]')
    ->template('your-template', [
        'name' => 'Alex',
        'action_url' => 'https://example.com/start',
    ], idempotencyKey: 'your-idempotency-key')
    ->attach(file_get_contents('/path/document.pdf'), 'document.pdf', 'application/pdf');

$mailer->send($email);