1. Go to this page and download the library: Download devster/rad-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/ */
devster / rad-mailer example snippets
// twig is optional, like from
$mailer = new Rad\Mailer($swiftmailer, $twig, $from = '[email protected]');
// Send a simple email
$nbEmailsSent = $mailer->send(array(
// Optional. By default the value set in the constructor.
// '[email protected]', array('[email protected]' => 'Bob', ...)
// or an object (see more details below)
'from' => '[email protected]',
// Same as from
'to' => '[email protected]',
// A twig template as string or a twig file template (ex: email.html.twig)
'subject' => 'Hello {{name}}!',
// Same as subject
'body' => 'body.html.twig',
// Optional. The data used in both templates subject and body
'data' => array('name' => 'Rob'),
// Optional, default: text/html. 'text/html' or 'text/plain'
'body_type' => 'text/plain'
));
// Send a more complex email
// Create a \Swift_Message pre set with data
$message = $mailer->createMessage(array(
'to' => '[email protected]',
'subject' => 'Hello {{name}}!',
'body' => 'body.html.twig',
'data' => array('name' => 'Rob'),
));
$message->attach(\Swift_Attachment::fromPath('/path/to/image.jpg'));
$nbEmailsSent = $mailer->sendMessage($message);