1. Go to this page and download the library: Download netglue/laminas-mail-utils 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/ */
netglue / laminas-mail-utils example snippets
declare(strict_types=1);
namespace App;
use Netglue\Mail\Validator\HasFromAddress;
use Netglue\Mail\Validator\HasSubject;
use Netglue\Mail\Validator\HasToRecipient;
use Netglue\Mail\Validator\TotalFromCount;
use Netglue\Mail\Validator\TotalRecipientCount;
use Netglue\Mail\Validator\TotalReplyToCount;
use Laminas\Validator\ValidatorChain;
use Laminas\Validator\ValidatorPluginManager;
final class PostmarkMessageValidator extends ValidatorChain
{
private const MAX_RECIPIENTS = 50;
public function __construct(?ValidatorPluginManager $pluginManager = null)
{
parent::__construct();
if ($pluginManager) {
$this->setPluginManager($pluginManager);
}
$this->configureDefaults();
}
private function configureDefaults() : void
{
$this->attachByName(HasFromAddress::class);
$this->attachByName(TotalFromCount::class, ['max' => 1]);
$this->attachByName(HasSubject::class);
$this->attachByName(HasToRecipient::class);
$this->attachByName(TotalRecipientCount::class, ['max' => self::MAX_RECIPIENTS]);
$this->attachByName(TotalReplyToCount::class, ['max' => 1]);
}
}
declare(strict_types=1);
namespace App\Postmark\Message;
use Netglue\Mail\Message\KeyValueMetadata;
use Netglue\Mail\Message\KeyValueMetadataBehaviour;
use Netglue\Mail\Message\OpenTracking;
use Netglue\Mail\Message\OpenTrackingBehaviour;
use Netglue\Mail\Message\TaggableMessage;
use Netglue\Mail\Message\TaggableMessageBehaviour;
use Laminas\Mail\Message;
class MyPostmarkMessage extends Message implements TaggableMessage, KeyValueMetadata, OpenTracking
{
use OpenTrackingBehaviour;
use TaggableMessageBehaviour;
use KeyValueMetadataBehaviour {
addMetaData as parentAddMetaData;
}
}
// $message is given to us from some factory or service somewhere
if ($message instanceof TaggableMessage) {
$someVendorApi->setMessageTag($message->getTag());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.