API Documentation

Build Coverage

Email Library documentation

Emailing usually happens in logic similar to this:

use Framework\Email\SMTP;
use Framework\Email\Message;

$mailer = new SMTP('', 'password');
$message = new Message($mailer);
$message->addTo('', 'Joe');
$message->setPlainMessage('Hello, Bro!');
$sent = $mailer->send($message);
if ($sent){
    echo 'Message successful sent';
} else {
    echo 'Message could not be sent:';

In just a few lines of code, the message can be sent.


The Mailer class must be loaded passing configuration data:

$mailer = new \Framework\Email\SMTP([
    'username' => '',
    'password' => 'password',
    'server' => '',
    'port' => 587,

And the message is sent with the send method:

$sent = $mailer->send($message);


The message must be instantiated with Mailer as a dependency.

Then, in it, the recipients, the plain and the HTML messages, and other data:

$message = new \Framework\Email\Message($mailer);
$message->setPlainMessage('Hello, Joe!');
$message->setHTMLMessage('Hello, <b>Joe</b>!');
$sent = $mailer->send($message); // Send the message

A message can have multiple attachments, sent separately or inline for images.

$message->setInlineAttachment(__DIR__ . '/image.png', 'abc123');

Where abc123 is the Content-ID:

<img src="cid:abc123" alt="An image with inline attachment">