PHP code example of enlitepro / enlite-mail

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

    

enlitepro / enlite-mail example snippets


array(
    'enlite_mail' => array(
        'renderer' => 'YOUR_RENDERER_FOR_MAIL', // default ViewRenderer
        'transport' => 'YOUR_TRANSPORT_FOR_MAIL', // default MailTransport
        'from_mail' => 'YOUR_MAIL',
        'from_name' => 'YOUR_NAME',
    )
)

array(
    'enlite_mail' => array(
        'renderer' => 'ZfcTwigRenderer',
        'transport' => 'MailTransport',
    )
)

array(
    'service_manager' => array(
        'invokables' => array(
            'MailTransport' => 'Zend\Mail\Transport\Sendmail',
        ),
    )
);

use EnliteMail\Service;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;

class MyService implements ServiceLocatorAwareInterface
{
    use ServiceLocatorAwareTrait,
        MailServiceTrait;

    public function test()
    {
        $mailService = $this->getMailService();

        // send any mail
        $message = $mailService->factoryMessage(); // this is Zend\Mail\Message
        // configure message
        // ...
        // send
        $mailService->sendMessage($message);

        // create mail from template and variables
        // variable will be pass to template
        $template = $mailService->createTemplate('my-module\controller\view', ['foo' => 'bar']);
        $mailService->sendTemplate($template, '[email protected]');
        // or, if you want operate message object before send
        $message = $mailService->createMessageFromTemplate($template);
        $mailService->sendMessage($message);
    }
}