Download the PHP package milosp/mailer-sdk without Composer

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

Mailer SDK

mailer-sdk is a PHP SDK for the mailer API

Getting started

Installing

You can install via Composer:

composer require milosp/mailer-sdk

or include the SDK under repositories in your composer.json file:

Usage

The Mailer class allows you to send emails by calling the API, or by dispatching messages into a RabbitMQ exchange, which the API will then also pick up. First, configure the Mailer:

Configuration

The mailer takes in an $options array as an argument with the following keys:

HTTP client configuration

By default, the SDK uses the Symfony HTTP client to make requests. If you have symfony/http-client installed, you don't need to do any configuration. If you want to use a different HTTP client (Guzzle, cURL...), just create an instance of the ApiClient class provided by the SDK. The ApiClient class uses PSR compliant interfaces to make it possible to integrate whatever http client you want to use. To create an instance of ApiClient, pass in the following arguments:

pass the object to the Mailer constructor:

AMQP client configuration

If you don't plan on dispatching messages into the API's queue, you don't need to pass in anything under the amqp_client key in the config. If you do want to dispatch messages, pass in an instance of the AmqpClient class:

and pass the object in the $options:

The $exchange and $routingKey parameters are optional and should be passed to the constructor if you only plan to dispatch messages into the same exchange and queue every time. If those might change, pass the $exchange and $routingKey into the sendAsMessage() method to configure these parameters on a per-message basis. If you use both the constructor and the method parameters, the parameters passed to sendAsMessage() take precedence.

Sending emails through the API

In order to send emails through the API, first assemble an EmailDto object. You can use the EmailBuilder class for this:

and then send the email:

The send() method returns the API's response as an instance of ResponseInterface.

You can also validate the email before getting the object to make sure you have the essential properties (subject, from, to and body) set:

You can also set API-specific things like an email template, body template or variables:

If you have an email template set up that fills in all the fields of an email, you can also do this:

You can also override specific fields of a template:

Sending emails by dispatching RabbitMQ messages

To do this, you must set up an AmqpClient, otherwise, a MailerException will be thrown when you try to dispatch a message.

When sending an email this way, you also create an EmailDto object, you just use a different method to send the email - sendAsMessage():

You can specify an exchange and routing key for the message here:

Authors


All versions of mailer-sdk with dependencies

PHP Build Version
Package Version
Requires psr/http-factory Version ^1.1
psr/http-client Version ^1.0
nyholm/psr7 Version ^1.8
php-amqplib/php-amqplib Version ^3.7
symfony/options-resolver Version ^7.3
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 milosp/mailer-sdk contains the following files

Loading the files please wait ...