PHP code example of synergitech / postal

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

    

synergitech / postal example snippets


return [
    'url' => 'https://yourpostal.io',
    'api_key' => 'ABCDEFGHI123456790',
    'send-name' => 'Your App Name',
    'send-address' => '[email protected]',
    'reply-to' => '[email protected]',
    'template_html' => 'email/generic/html',
    'template_text' => 'email/generic/text'
];

return [
    // ...
    'sendallmessagesto' => '[email protected]'
    // ...
];

\Synergitech\Postal::send($subject, $body, $to, $to_name, $from, $data, $bcc);

$message = \Synergitech\Postal\SendMessage::forge($subject, $body, $data, $from);

$message->to('[email protected]');
$message->cc('[email protected]', 'Accounts Department');

$message->bcc(array(
    '[email protected]' => 'Tom',
    '[email protected]' => 'Dick',
    '[email protected]' => 'Harry'
));

$message->attach('report.pdf', 'application/pdf', file_get_contents('report.pdf'));

$message->send();

$message = \Synergitech\Postal\SendMessage::forge($subject, null, ['body_view' => $bodyview] + $data);

\Synergitech\Postal\Webhook::ProcessWebhook();

namespace Controller;

class Webhook extends \Controller_Rest
{
    public function action_postal()
    {
        \Synergitech\Postal\Webhook::ProcessWebhook();
    }
}

$sent = $message->send();

$log = \Model\Audit\Log::forge(array(
    // your specific information here
));

$log->save();

foreach ($sent as $email) {
    \Model\Audit\Item::forge(array(
        'log_id' => $log->id,
        'email_id' => $email->id
    ))->save();
}
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
php composer.phar 
bash
php oil r migrate --packages=postal