PHP code example of pendable / symfony-mailer

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

    

pendable / symfony-mailer example snippets



// config/services.php

return [
    Pendable\SymfonyMailer\Transport\PendableTransportFactory:
        tags: [ mailer.transport_factory ]
];

$email = (new Email())
  ->from('[email protected]')
  ->to('[email protected]')
  // ->cc('...')
  // ->addCc('...')
  // ->bcc('...')
  // ->replyTo('...')
  ->subject("Subject")
  ->html('<p>Html content of Symfony Pendable email.</p>')
  ->text('Text content of your Symfony Pendable text-only email.');

$email->getHeaders()
    ->add(new MetadataHeader('key-1', 'value-1')) // Custom field called 'key-1'
    ->add(new MetadataHeader('key-2', 'value-2')) // Custom field called 'key-2'
    ->add(new TagHeader('TagInHeaders1')) // Tags
    ->add(new TagHeader('TagInHeaders2')) // Tags
    ->addTextHeader('priority', 60)
    ->addTextHeader('config_identifier', 'custom key')
    ->addTextHeader('client_email_id', '123476AB')
    ->addTextHeader('schedule_send_at', '2023-06-25T22:37:26+05:30');

// Send the email using the custom Pendable transport
try {
    $resp = $mailer->send($email);
    return new Response('Email sent successfully to Pendable.');
} catch (\Exception $e) {
    return new Response('Failed to send email to Pendable: ' . $e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
}