PHP code example of jinexus / zend-notification

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

    

jinexus / zend-notification example snippets


 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->setTo('[email protected]', 'Recipient Name')
    ->setSubject('Sample Subject')
    ->setContent(
        'This is the body/content of the email, you can write here your thoughts.' .
        'I\'ve got everything yet nothing to write, for my thoughts are in a constant fight.'
    )
    ->send();

 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->setTo('[email protected]', 'Recipient One')
    ->addTo('[email protected]', 'Recipient Two')
    ->addTo('[email protected]', 'Recipient Three')
    ->setSubject('Your character defines you')
    ->setContent(
        'There are two things that defines you. Your patience to learn when you don\'t know anything, 
        and your attitude to share when you know everything.'
    )
    ->send();

 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->setTo(['[email protected]', '[email protected]'], 'Common Name')
    ->setSubject('What makes me superior?')
    ->setContent(
        'The fact that I don\'t believe that I\'m better than anyone else 
        gives me an inevitable sense of superiority.'
    )
    ->send();

 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->addTo(['[email protected]', '[email protected]'], 'Common Name')
    ->setSubject('I\'m from 90\'s')
    ->setContent(
        'Let me tell you about a magical time. The rock stars were suicidal, 
        the rappers were criminals, and wrestling was real. It was the 90\'s'
    )
    ->send();

 

$notification->setCc('[email protected]', 'Recipient Cc');
$notification->setBcc('[email protected]', 'Recipient Bcc');

 
$notification->addCc('[email protected]', 'Recipient Cc');
$notification->addBcc('[email protected]', 'Recipient Bcc');

 
$notification->setReplyTo('[email protected]', 'Jimvirle');

 
$notification->addReplyTo('[email protected]', 'Jimvirle');


/*
 * Mail headers created:
 * From: Kheven Bitoon <[email protected]>, Rogelio Carrillo <[email protected]>
 * Sender: Jimvirle Calago <[email protected]>
 */
$notification->addFrom('[email protected]', 'Kheven Bitoon');
$notification->addFrom('[email protected]', 'Rogelio Carrillo');
$notification->setSender('[email protected]', 'Jimvirle Calago');

 
/*
 * This will set your email to a text content.
 */
$notification->setType('text');

 
/*
 * This will set your email to an html content.
 */
$notification->setType('html');

 
/*
 * You can also set multiple attachments.
 */
$notification->setAttachments([
    'absolute-path-of-the-file.jpg',
    'this-is-a-multiple-attachment.pdf',
]);

 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->setTo('[email protected]', 'Recipient Name')
    ->setSubject('Sample Subject')
    ->assemble()
    ->send();

 
use JiNexus\Zend\Notification\Notification;

$notification = new Notification();
$notification->setFrom('[email protected]', 'Sender Name')
    ->setTo('[email protected]', 'Recipient Name')
    ->setSubject('Sample Subject')
    ->setConfig([
            'notification' => [
                'footer' => __DIR__ . '/src/view/layout/footer.phtml',
                'header' => __DIR__ . '/src/view/layout/header.phtml',
                'layout' => __DIR__ . '/src/view/layout/layout.phtml',
                'template' => __DIR__ . '/src/view/template/confirmation-email.phtml',
            ]
        ])
    ->assemble()
    ->send();

 
$notification->setHeaderData(['greetings' => 'Hello from the other side!']);

 echo $this->greetings; 

 
$notification->setFooterData([
    'company' => 'JiNexus Inc.',
    'address' => 'Cebu City, Cebu, 6000, PH',
]);

 echo $this->company; 

 
$notification->setTemplateData([
    'fullName' => 'Jimvirle Calago',
    'message' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
    'token' => '$2y$10$2pebvLw6RhmqiybYg6qNr.F.lCIEYf0HzPrKAxNTsrRZLRI5uhh1m'
]);

 echo $this->fullName; 

 
$notification->setTransport('sendmail');
$notification->setSendmailTransportParameters('[email protected]');
$notification->send();

 
$notification->setTransport('smtp');
$notification->setSmtpTransportOptions([
    'host' => 'smtp.gmail.com',
    'port' => 587,
    'connection_class'  => 'plain',
    'connection_config' => [
        'username' => '[email protected]',
        'password' => 'my-app-password',
        'ssl' => 'tls',
    ],
]);
$notification->send();

 
$notification->setTransport('inMemory');
$notification->send();