Search by

leoflapper / mailprovider

leoflapper

This package is abandoned and no longer maintained. No replacement package was suggested.

Allows you to quickly send mails with different mail services like PHPMailer, Mandrill, SendGrind and Mailgun

Package info

github.com/leoflapper/mailprovider

Homepage

pkg:composer/leoflapper/mailprovider

Statistics

Installs: 1 544

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 1

v1.1.2 2021-12-06 18:43 UTC

This package is not auto-updated.

Last update: 2026-11-22 06:53:18 UTC


README

MailProvider allows you to quickly send mails with PHPMailer or different mail services like Mandrill, SendGrind or Mailgun.

Usage

The MailProvider allows you to compose an email in a single format. You only have to choose the desired service.

PHPMailer

    $service = new MailProvider\Service\PHPMailer();
    $service
        ->setProtocol('smtp')
        ->setHost('localhost')
        ->setPort(1025)
        ->addTo('info@myemail.nl', 'Leo Flapper')
        ->addCc('cc@myemail.nl', 'Leo Flapper')
        ->addBcc('bcc@myemail.nl', 'Leo Flapper')
        ->setFrom('info@myhost.nl', 'Leo Flapper')
        ->setSubject('My Subject')
        ->setHtml('<p>Beautiful content</p>')
        ->addAttachment('../LICENSE.md', 'Attachment.txt')
        ->addHeader('MyHeader', 'Value')
        ->setReplyTo('reply@myemail.nl');

    $service->send();

Other mail services

    //$service = new MailProvider\Service\SendGrid('API-KEY');
    //$service = new MailProvider\Service\Mailgun('API-KEY');
    $service = new MailProvider\Service\Mandrill('API-KEY');
    $service
        ->addTo('info@myemail.nl', 'Leo Flapper')
        ->addCc('cc@myemail.nl', 'Leo Flapper')
        ->addBcc('bcc@myemail.nl', 'Leo Flapper')
        ->setFrom('info@myhost.nl', 'Leo Flapper')
        ->setSubject('My Subject')
        ->setText('My text')
        ->setHtml('<p>Beautiful content</p>')
        ->addAttachment('../LICENSE.md', 'Attachment.txt')
        ->addHeader('MyHeader', 'Value')
        ->setReplyTo('reply@myemail.nl');
    $service->send();

Installation

Add MailProvider to your composer.json file. If you are not using Composer, you should be. It's an excellent way to manage dependencies in your PHP application.

{  
  "require": {
    "leoflapper/mailprovider": "dev-master"
  }
}

Then at the top of your PHP script require the autoloader:

require 'vendor/autoload.php';

Example

There are different examples located inside the examples directory.

Credits

License

The MIT License (MIT). Please see License File for more information.