Queuing emails

In order to utilise the queueing functionality added to Continuum #19, the Mail service provides a queue() method which accepts two parameters, the queue name and an instance of an instance of Jadu_Container_Mail.

The queue method will attempt to push the data onto the queue, otherwise it will send the email straight away.

Adding emails to the Queue

$mail->queue('jadu.email', $data);

Sending an email

Instead of passing an instance of Jadu_Container_Mail - the send() method would expect the user to pass a callable (Closure). The callable would then pass an instance of MessageInterface as a param to the Closure.

$mail = Jadu_Service_Container::getInstance()->getMail();

$mail->send(function($message)
{
    $message->setFrom('no-reply@jadu.net');
    $message->addTo('your.email@jadu.net');
    $message->setSubject('Hello World!');
    $message->setBody('Welcome to Jadu.net');

    // must return $message instance
    return $message;
});

HTML emails

$message->setContentType('text/html');
$message->setBody('<h1>Hello World!</h1>');

Adding an attachment

use JaduFramework\Mail\Drivers\SwiftMailer\Attachment;
$message->addAttachment(new Attachment('/path/to/file.ext'));

results matching ""

    No results matching ""