PHP code example of swarletta / swiftmailer

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

    

swarletta / swiftmailer example snippets

 php


ilTransport\MailTransport;
use App\MailTransport\Message;
use App\Render\Render;

$dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__);
$dotenv->load();

$mailTransport = new MailTransport(
    getenv('HOST'),
    (int) getenv('PORT'),
    getenv('USER_EMAIL'),
    getenv('USER_PASSWORD'),
    'ssl'
);
$templateName = 'auth';
$message = 'You have been successufuly authorization';
$templateMessage = (new Render())->build_email_template($templateName, $message);

$mailTransport->send( new Message('Welcome', $templateMessage, getenv('EMAIL_TO')));