PHP code example of laasti / mailer

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

    

laasti / mailer example snippets



use Laasti\Mailer;
$server = new Servers\SMTP($logger, $host, $username, $password, $port);
$ok = (new Mailer($server))
    ->setFrom('You', '') //your name, your email
    ->setFakeFrom('heelo', '[email protected]') // if u want, a fake name, a fake email
    ->addTo('Cloud', '[email protected]')
    ->setSubject('Test Mailer')
    ->setBody('Hi, I <strong>love</strong> you.')
    ->addAttachment('host', '/etc/hosts')
    ->send();
var_dump($ok);


use Laasti\Mailer\Servers\SMTP;
use \Laasti\Mailer\Message;
use \Monolog\Logger;

$server = new SMTP($logger, $host, $username, $password, $port);
$mailer = new Mailer($server);

$message = new Message();
$message->setFrom('Tom', '[email protected]') // your name, your email
    ->setFakeFrom('heelo', '[email protected]') // if u want, a fake name, a fake email
    ->addTo('Cloud', '[email protected]')
    ->setSubject('Test Mailer')
    ->setBody('<h1>For test</h1>')
    ->addAttachment('host', '/etc/hosts');

$ok = $mailer->send($message);
var_dump($ok);