lzaplata/smartemailing

There is no license information available for the latest version (dev-master) of this package.

SmartEmailing wrapper for Nette Framework.

dev-master 2018-02-13 08:37 UTC

This package is auto-updated.

Last update: 2024-04-25 06:14:48 UTC


README

This is small Nette Framework wrapper for SmartEmailing.

Installation

The easiest way to install library is via Composer.

$ composer require lzaplata/smartemailing: dev-master

or edit composer.json in your project

"require": {
        "lzaplata/smartemailing": "dev-master"
}

You have to register the library as extension in config.neon file.

extensions:
        smartEmailing: LZaplata\SmartEmailing\DI\Extension

Now you can set parameters...

smartEmailing:
        username           : *
        apiKey             : *

...and autowire library to presenter

use LZaplata\SmartEmailing\Client;

/** @var Client @inject */
public $smartEmailingClient;

Usage

Import contact

try {
    $this->smartEmailingClient->importContact($email, $contactlistId);
} catch (\Exception $e) {
    echo $e->getMessage();
}

Get single email

try {
    $request = $this->smartEmailingClient->getEmail($id);
    
    echo $request->json();
} catch (\Exception $e) {
    echo $e->getMessage();
}

Send custom email

First of all you have to declare LZaplata\SmartEmailing\Helpers\Email object and then pass it as parameter to sendCustomEmail function.

try {
    $email = new Email();
    $email->setSender($senderEmail, $senderName);
    $email->setRecipient($recipientEmail, $recipientName);
    $email->setSubject($subject);
    $email->setHtmlBody($html);
    $email->setTag($tag);
    $email->setReplacements([
        "key" => "content"
    ]);

    $this->smartEmailingClient->sendCustomEmail($email);
} catch (\Exception $e) {
    echo($e->getMessage());
}