2017 © Pedro PelĆ”ez
 

library mail

Integration of various email service providers in the Zend Framework Zend\Mail

image

slm/mail

Integration of various email service providers in the Zend Framework Zend\Mail

  • Tuesday, February 27, 2018
  • by juriansluiman
  • Repository
  • 13 Watchers
  • 101 Stars
  • 184,681 Installations
  • PHP
  • 7 Dependents
  • 1 Suggesters
  • 40 Forks
  • 15 Open issues
  • 23 Versions
  • 5 % Grown

The README.md

SlmMail

Build Status Latest Stable Version Scrutinizer Code Quality, (*1)

SlmMail is a module that integrates with various third-parties API to send mails. Integration is provided with the API of those services. It does not handle SMTP., (*2)

Here are the currently supported services:, (*3)

Requirements

Installation

  1. First install the repo:, (*4)

    composer require slm/mail, (*5)

  • For Laminas MVC add SlmMail in your application.config.php file.
  • For Mezzio it should prompt whether we want to autoconfigure. Accept this.
  1. In order to use a mail service, you now need to configure it. We have provided a sample configuration file per mail server., (*6)

    Copy the sample configuration file to your autoload directory. For example for Mandrill one would use, (*7)

    cp vendor/slm/mail/config/slm_mail.mandrill.local.php.dist config/autoload/slm_mail.mandrill.local.php, (*8)

    Please tweak the dummy contents in this file. This file will contain the credentials., (*9)

Usage

One can now fetch the dependencies from the service manager. And now compose a message:, (*10)

$message = new \Laminas\Mail\Message();
$message
    ->setTo('send@to')
    ->setFrom('send@by')
    ->setSubject('Subject')
    ->setBody('Contents');

$mandrillService = $container->get(\SlmMail\Service\MandrillService::class);
$mandrillService->send($message);
```` 

Documentation
-------------

Documentation for SlmMail is splitted for each provider:

* [Elastic Email](/docs/ElasticEmail.md)
* [Mailgun](/docs/Mailgun.md)
* [Mandrill](/docs/Mandrill.md)
* [Postage](/docs/Postage.md)
* [Postmark](/docs/Postmark.md)
* [SendGrid](/docs/SendGrid.md)
* [SparkPost](/docs/SparkPost.md)
* [Amazon SES](/docs/Ses.md)

Cook-book
---------

### How to send an HTML email ?

Every email providers used in SlmMail allow to send HTML emails. However, by default, if you set the mail's content
using the `setBody` content, this content will be considered as the plain text version as shown below:

```php
$message = new \Laminas\Mail\Message();

// This will be considered as plain text message, even if the string is valid HTML code
$message->setBody('Hello world');

To send a HTML version, you must specify the body as a MimeMessage, and add the HTML version as a MIME part, as shown below:, (*11)

$message = new \Laminas\Mail\Message();

$htmlPart = new \Laminas\Mime\Part('<html><body>

Hello world

</body></html>'); $htmlPart->type = "text/html"; $textPart = new \Laminas\Mime\Part('Hello world'); $textPart->type = "text/plain"; $body = new \Laminas\Mime\Message(); $body->setParts(array($textPart, $htmlPart)); $message->setBody($body);

For accessibility purposes, you should always provide both a text and HTML version of your mails., (*12)

How to configure HttpClient with http_options and http_adapter

By default the adapter is Laminas\Http\Client\Adapter\Socket but you can override it with other adapter like this in your slm_mail.*.local.php, (*13)

'slm_mail' => array(
    // Here your email service provider options

    'http_adapter' => 'Laminas\Http\Client\Adapter\Proxy' // for example
)

If you want to change some options of your adapter please refer to you adapter class in var $config here and override these in your slm_mail.*.local.php like this :, (*14)

'slm_mail' => array(
    // Here your email service provider options

    // example for Socket adapter
    'http_options' => array(
        'sslverifypeer' => false,
        'persistent' => true,
    ),
)

Which provider should I choose?

We won't answer you :-)! Each provider has their own set of features. You should carefully read each website to discover which one suits your needs best., (*15)

Who to thank?

Jurian Sluiman and Michaƫl Gallego did the initial work on creating this repo, and maintained it for a long time., (*16)

Currently it is maintained by:, (*17)

The Versions

07/07 2016

v2.0.0

2.0.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

15/01 2016

v1.6.0

1.6.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

04/05 2015

v1.5.3

1.5.3.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

31/12 2014

v1.5.2

1.5.2.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

07/11 2014

v1.5.1

1.5.1.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

12/06 2014

v1.5.0

1.5.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun transactional email elasticemail postage elastic email send grid

14/04 2014

v1.4.1

1.4.1.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

04/04 2014

v1.4.0

1.4.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

14/02 2014

v1.3.2

1.3.2.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

28/12 2013

v1.3.1

1.3.1.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

05/11 2013

v1.3.0

1.3.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

14/10 2013

v1.2.0

1.2.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

10/09 2013

v1.1.1

1.1.1.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

10/09 2013

v1.1.0

1.1.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

09/07 2013

v1.0.1

1.0.1.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

31/05 2013

v1.0.0

1.0.0.0 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

28/05 2013

v1.0.0-rc3

1.0.0.0-RC3 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

15/05 2013

v1.0.0-rc2

1.0.0.0-RC2 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail

09/05 2013

v1.0.0-rc1

1.0.0.0-RC1 https://github.com/juriansluiman/SlmMail

Integration of various email service providers in the Zend Framework Zend\Mail

  Sources   Download

The Requires

 

The Development Requires

email zf2 mandrill sendgrid postmark mailgun alphamail transactional email elasticemail postage elastic email send grid alpha mail