PHP code example of slick / mail

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

    

slick / mail example snippets

 php
use Slick\Mail\Mime;
use Slick\Mail\Mime\MimeMessage;
use Slick\Mail\Mime\Part as MimePart;

$text = new MimePart('mail/template.twig', ['foo' => $foo, 'bar' => 'baz']);
$text->type = "text/plain";

$image = new MimePart('image.jpg');
$image->type = "image/jpeg";
$image->id = "image";
$image->encoding = Mime::ENCODING_BASE64;

$html = new MimePart('mail/template.html.twig', ['foo' => $foo, 'bar' => 'baz']);
$html->type = "text/html";

$message = new MimeMessage();
$message->parts()
    ->add($text)
    ->add($image)
    ->add($html)
;

 php
use Slick\Mail\Transport\SmtpTransport;

$transport = new SmtpTransport([
    'options' => [
        'name' => 'localhost.localdomain',
        'host' => '127.0.0.1',
        'port' => 25,
    ]
]);

$transport->send($message);