PHP code example of janmalte / jm-mail-service

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

    

janmalte / jm-mail-service example snippets


    
    return array(
        'modules' => array(
            // ...
            'JanMalte\JmMailService',
        ),
        // ...
    );
    

    // Get the mail service
    $mailService = $serviceLocator->get('JanMalte\JmMailService\Service\Mail');
    

    // Reset the mail service
    $mailService->reset();

    // Set the mail template
    $mailService->setTemplate($templateFile);

    // Parse the template
    $mailService->parseTemplate($templateValues);

    // Add a recipient for the message
    $mailMessage = $mailService->getMailMessage();
    $mailMessage->setTo($recipientEmail, $recipientName);

    // Send the mail message
    $mailService->send();
    

    // Use the mail service with method chaining
    $mailService->reset()
        ->setTemplate($templateFile)
        ->parseTemplate($templateValues);

    // Add a recipient for the message
    $$mailService->getMailMessage()
        ->setTo($recipientEmail, $recipientName);

    // Send the mail message
    $mailService->send();
    
bash
    $ php composer.phar update