PHP code example of kodus / mail

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

    

kodus / mail example snippets


$message = new Message(
    new Address($email),        // recipient
    new Address("[email protected]"), // sender
    "Hello, Person!",           // subject
    $text                       // plain text message body
);

$message->addAttachment(Attachment::fromFile(__DIR__ . "/awsum/unicorns.gif"));

$service->send($message);

$service = new SMTPMailService(
    new SocketConnector("localhost", 25),
    new LoginAuthenticator("user", "super_secret_pa55w0rd"),
    "test.org"
);

$service = new MailServiceLogger($psr_logger, new SMTPMailService(...));