Download the PHP package meil/meil-php without Composer

On this page you can find all versions of the php package meil/meil-php. 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 meil-php

meil-php

The official PHP client for the meil.ro API: transactional email and newsletters.

Keys are the API's own field names (reply_to, template_id, audience_id), so the API docs and this package read the same.

Sending email

With a saved template and its placeholders:

With attachments. Pass the file's raw bytes as content, and the SDK base64-encodes them. Do not encode them yourself. You can attach up to 20 files, 7 MB in total.

The answer is ['id' => ...]. It can also have unsubscribe_url, and suppressed when some recipients on your suppression list were skipped.

Idempotency keys

emails->send() and broadcasts->create() always send an Idempotency-Key. If you give none, the SDK makes a random UUID for the call, which makes its own retries safe. To make your own retries safe too (a cron job or queue worker that runs twice, say), pass a key that is unique to the send:

For 24 hours, the same key with the same body returns the first answer and sends nothing new. The same key with a different body throws a ConflictException with the error name invalid_idempotent_request.

Errors

Failed calls throw. Every exception is a Meil\Exception\MeilException (a RuntimeException) with these methods:

Exception (Meil\Exception\…) When
AuthenticationException 401, a missing or invalid key
PermissionException 403: key scope, plan, suspended account, recipient_suppressed
NotFoundException 404, also for objects of a domain your key is not locked to
ConflictException 409: idempotency conflicts
ValidationException 422, including send_rejected
RateLimitException 429, with getRetryAfter() in seconds when the API sends one
ServerException 5xx, including Cloudflare error pages (error name invalid_response)
ConnectionException no answer: connection_error or timeout, status null

Retries

By default the SDK retries up to 2 times. Set max_retries to change that; 0 turns retries off.

It retries:

Quotas (daily_quota_exceeded, monthly_quota_exceeded, previous_broadcast_pending) are never retried. GET, PATCH and DELETE calls are retried. A POST is retried only when it carries an Idempotency-Key, which means only emails->send() and broadcasts->create().

The SDK waits between retries with usleep(), so a web request that hits a rate limit can take a few extra seconds. For a page that must answer quickly, set 'max_retries' => 0.

Broadcasts

$meil->broadcasts->send($id) sends a draft. It can also return the under_review result.

Other broadcast methods: get, list, update, delete, schedule($id, $date) and unschedule.

Contacts

The SDK URL-encodes the email addresses in paths for you.

Paging

emails->list() and audiences->listContacts() return one page: ['object' => 'list', 'has_more' => bool, 'data' => [...]]. To get everything, loop over the generator. Pages are fetched as you go:

The other lists (audiences->list(), broadcasts->list(), templates->list()) return everything at once.

All methods

Resource Methods
emails send, list, iterate, get
audiences create, list, get, delete, listContacts, iterateContacts
contacts add, get, update, delete, remove
broadcasts create, list, get, update, delete, send, schedule, unschedule
templates create, list, get, update, delete
content check

A key's scope decides what it may call. email_access keys get emails and the content check; broadcast_access keys get everything except audiences and contacts. The SDK does not check scopes: the API answers with a PermissionException (insufficient_permission).

Timestamps

Timestamps in answers (created_at, scheduled_at, sent_at, ...) are UTC strings formatted "YYYY-MM-DD HH:MM:SS", returned as the API sends them. To parse one: new DateTimeImmutable($email['created_at'], new DateTimeZone('UTC')).

WordPress and shared hosting

The package has no Composer dependencies. Without Composer, require the files with a small PSR-4 autoloader for the Meil\ namespace, which maps to src/:

To send through something other than cURL (WordPress's HTTP API, a PSR-18 client), implement Meil\Transport\TransportInterface and pass it as the transport option.

Development

License

MIT


All versions of meil-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-curl Version *
ext-json Version *
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 meil/meil-php contains the following files

Loading the files please wait ...