1. Go to this page and download the library: Download jack33232/zjemailservice 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/ */
jack33232 / zjemailservice example snippets
use ZJEmailService\EmailPostbox;
use Katzgrau\KLogger\Logger;
// All possible settings, please refer to PHPMailer Doc
$postbox_setting = [
'Host' => 'example.exchange.com',
'Port' => 25,
'ContentType' => 'text/html',
'SMTPAuth' => true,
'SMTPSecure' => 'tls',
'CharSet' => 'UTF-8',
'Encoding' => 'base64',
'SMTPOptions' => array(),
'Timeout' => 300,
'SMTPDebug' => 0,
'Debugoutput' => 'error_log' // only works when no debugger assigned
];
// Postbox name
$postbox_name = 'example';
// PSR logger
$debugger = new Logger(__DIR__.'/logs');
EmailPostbox::register($postbox_setting, $postbox_name, $debugger);
use ZJEmailService\EmailPostbox;
$username = '[email protected]';
$password = 'password123';
$from = 'Username';
$postbox_name = 'example';
// The postbox is a singleton
$postbox = EmailPostbox::unlock($username, $password, $from, $postbox_name);
use ZJEmailService\Envelope;
// Third parameter is the priority of the email
$envelope = new Envelope('Test', 'Some text as email body', 'HIGH');
$envelope->setTo(['[email protected]', 'To Name']);
$postbox->send($envelope);