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

Warning This package relies on slm, which is abandoned and will receive no further development. For that reason, we don't recommend starting any project with this package. Instead take a look at https://github.com/omnimail/omnimail or use symfony/mailer with a 3rd Party Transport., (*1)


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

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., (*3)

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

Installation

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

    composer require slm/mail, (*6)

  • 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., (*7)

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

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

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

Usage

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

$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:, (*12)

$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., (*13)

multipart/alternative emails with attachments

The correct way to compose an email message that contains text, html and attachments is to create a multipart/alternative part containing the text and html parts, followed by one or more parts for the attachments. See the Laminas Documentation for a full example., (*14)

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, (*15)

'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 :, (*16)

'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., (*17)

Who to thank?

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

Currently it is maintained by:, (*19)

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