Download the PHP package mailjet/mailjet-apiv3-php-simple without Composer

On this page you can find all versions of the php package mailjet/mailjet-apiv3-php-simple. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mailjet-apiv3-php-simple

READ THIS FIRST!!
This repository is now considered deprecated and won't undergo further development. Please refer to the new one.

[API v3] Mailjet PHP Wrapper v1.1.0

Build Status

Table of Contents

Introduction

Provides a simple PHP library for the last version of the MailJet API. The goal of this component is to simplify the usage of the MailJet API for PHP developers.

Prerequisites

Make sure to have the following details:

Installation

First clone the repository

Go into the mailjet-apiv3-php-simple folder and create an empty file named (for example) myProjectEmailer.php

You are now ready to go !

Usage

In your myProjectEmailer.php file, you need to include our php class:

Be Careful: Make sure that both myProjectEmailer.php and php-mailjet-v3-simple.class.php files are in the same folder to make this include work

Now you can start working with the myProjectEmailer.php file by creating a new Mailjet object with your api key and secret key (you can find these at https://app.mailjet.com/account/api_keys):

This basically starts the engine. Now what you're going to do next depends on what you want to GET, POST, PUT or DELETE from the Mailjet servers through the API. Take a tour on the Reference documentation to see all the resources available.

Next you will specify which resource to call this way (resource Contact in this example) with an array of parameters $params:

Info: If you don't specify the method of the request in the array $params (see examples below), it will be a GET.

Examples

SendAPI

A function to send an email:
A function to send an email with some attachments (absolute paths on your computer):
A function to send an email with some inline attachments (absolute paths on your computer):
A function to send an email with a custom ID, as described here:
A function to send an email with a event payload, as described here:

Account Settings

A function to get your profile information:
A function to update the field AddressCity of your profile:

Contact & Contact Lists

Reference page.

Principle functionalities

A function to print the list of your contacts:
A function to update your contactData resource with ID $id, using arrays:
A function to create a list with name $Lname:
A function to get a list with ID $listID:

Note: You can use unique fields of resources instead of IDs, like "unique" => "[email protected]" in your params array for this example

A function to create a contact with email $Cemail:
A function to get the lists for a single contact which ID is $contactID:
A function to add the contact which ID is $contactID to the list which ID is $listID:

The preferred method to add a single contact to a list is described at the next bullet point.

A function to add the contact described in $contact to the list which id is $listID:

Note:
action can be addforce, addnoforce, remove or unsub.

A function to add, remove or unsub the contact which ID is $contactID to / from the list(s) contain(ed) in $lists:

Note:
action can be addforce, addnoforce, remove or unsub.

A function to delete the list which ID is $listID:
A function to get unsubscribed contact(s) from a list with ID $listID:
A function to get a contact with ID $contactID:

Note: You can use unique fields of resources instead of IDs, like "unique" => "[email protected]" in your params array for this example

Asynchronous jobs

An asynchronous job (in short, async job) is a way to add or update massive amount of data (contacts, for example) in an all-in-one call which will return a job id used to check on the progress of the job via another call.

Performing an async job on the contact resource

A function to asynchronously add, remove or unsub contact(s) to/from one or more list(s) and returns the status array for the job:
(Useful for uploading lots of contacts to one or more list(s) at once.)

This example shows how to remove the given contacts from one list and add them to another (if they are not in it). In one call.

Note:
action can be addforce, addnoforce, remove or unsub.

Performing an async job on the contactslist resource

A function to asynchronously add, remove or unsub contact(s) to/from a list and return the status array for the job:

This example shows how to unsub contacts from a contacts list.

Note:
action can be addforce, addnoforce, remove or unsub.

Monitoring an async job

A function to get the status of a previously launched asynchronous job:

Note: This works both with the contact and the contactslist resources. Adjust the commented code below accordingly.

Managing contacts in a contactslist from a CSV file

"Managing" here means adding, removing or unsubscribing.

In some cases you might need to manage large quantities of contacts stored into a CSV record in relation to a contactslist. Here is how to proceed using the PHP Wrapper.

Please note that these steps represent a single process. Don't execute each step independently but, rather, as a whole.
You can find a sample script here.

Step zero: CSV file structure.

The structure for the CSV file should be as follows:

Please note that undefined contact properties present in the CSV file will be automatically created during the second step.

First step: upload the data

The first step is to upload the csv data to the server.
You need to specify the wanted contactslist ID and, of course, the csv_content.

Second step: Manage the contacts subscription to the contactslist

Now, you need to tell the API that this uploaded data has to be assign to the given contactslist resource.

Please note that method and Method are not the same field.
Method describes how the contacts import will behave. Possible values are addforce, addnoforce, remove and unsub.

Third step: Monitor the process

What is left to do is to make sure the task completed successfully, which might require multiple checks as a huge amount of data may take some time to be processed (several hours are not uncommon).

Newsletters

Managing the content of a newsletter

You can use the DetailContent action to manage the content of a newsletter, in Text and Html. It has two properties: Text-part and Html-part. You can use GET, POST, PUT and DELETE both requests on this action:

Example with a GET on DetailContent:

Scheduling a newsletter

Use the schedule action to send a newsletter later. You just need to perform a POST request to schedule a new sending and to fill the date property with a Timestamp format in ISO 8601: http://www.iso.org/iso/home/standards/iso8601.htm You can also DELETE a schedule Here is an example:

Sending a newsletter immediately

To send a newsletter immediately, you have two possibilities:

Sending a newsletter to test recipients

You can also test a newsletter by sending it to some specified recipients before making the real sending. To do so, you have to perform a POST request on a newsletter with action test like in the following example:

Duplicating an existing newsletter

To duplicate an existing Newsletter, use the DuplicateFrom filter, with the Newsletter ID to duplicate. EditMode is html if the Newsletter was built using the API or advanced mode. If you used our WYSIWYG tool, set it to tool:

Filtering

The API allows for filtering of resources on GET and POST requests.
However, there is a difference in how you need to specify the filters you want to use in your payload hod, depending on the method you want to use:

For GET requests:

This is easy. Simply append the filter to your parameters array, like you would for an extra parameter.

Need to show more than the first 10 contacts in a contactslist the API response contains? Use the limit filter:

For POST requests:

For filters using that method, the wrapper needs to be able to differentiate between a parameter and a filter.
How? Simply append a "_" (underscore character) at the beginning of the filter's name.

Want to duplicate a newsletter? Do:

Reporting issues

Open an issue here.


All versions of mailjet-apiv3-php-simple with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mailjet/mailjet-apiv3-php-simple contains the following files

Loading the files please wait ....