PHP code example of symfony / sweego-mailer

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

    

symfony / sweego-mailer example snippets


use Symfony\Component\Mime\Email;

$email = new Email();
$email
    ->to('[email protected]')
    ->from('[email protected]')
    ->subject('Email with attachments')
    ->text('Here is the text version')
    ->html('<p>Here is the HTML content</p>')
    // Regular attachment
    ->attach('Hello world!', 'test.txt', 'text/plain')
    // Inline attachment (embedded image)
    ->embed(fopen('image.jpg', 'r'), 'image.jpg', 'image/jpeg')
;

#[AsRemoteEventConsumer(name: 'sweego_mailer')]
class SweegoMailEventConsumer implements ConsumerInterface
{
    public function consume(RemoteEvent|AbstractMailerEvent $event): void
    {
        // your code
    }
}