lianhua / easy-mailjet
A simple library for sending email through mailjet service
Requires
- php: >=7.3
- lianhua/email: ^1.0.1
- mailjet/mailjet-apiv3-php: ^1.4
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2023-05-19 19:40:49 UTC
README
Overview
A simple PHP class for sending emails through Mailjet provider
Compatibility
This library has been tested for PHP 7.3 and higher
Installation
Just use composer in your project:
composer require lianhua/easy-mailjet
If you don't use composer, clone or download this repository, all you need is inside the src directory. You'll need Lianhua Email and Mailjet API PHP Wrapper
Usage
Mailjet object
In order to create maijet object, you'll need your api keys and give them to the constructor.
$mj = new EasyMailjet("Your key", "Your secret");
Sending an email
Create an object of type Lianhua Email and give it to the function sendMail.
$mj->sendMail($email);
You'll get in return a boolean indicating if the email had been sent successfully or not.
Get mailjet detailed response
If you give a var as second parameter, you'll be able to get the response from mailjet (read Mailjet Documentation for further explanations)
$mj->sendMail($email, $res);
Send with custom ids
You can give as third and fourth parameters a custom id for the campaign and the message.
$mj->sendMail($email, $res, "campaign_id", "message_id");
Sandbox mode
You can disable the email delivering while getting a feedback from mailjet.
$mj->setSandbox(true);
Deduplicate mode
You can disable duplicate contacts in a campaign.
$mj->setDeduplicate(true);