2017 © Pedro Peláez
 

library mailer

Berlioz Mailer

image

berlioz/mailer

Berlioz Mailer

  • Friday, June 29, 2018
  • by ElGigi
  • Repository
  • 1 Watchers
  • 1 Stars
  • 116 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Berlioz Mailer

Latest Version Software license Build Status Quality Grade Total Downloads, (*1)

Berlioz Mailer is a PHP library for sending mail, with or without local server., (*2)

Installation

Composer

You can install Berlioz Mailer with Composer, it's the recommended installation., (*3)

$ composer require berlioz/mailer

Dependencies

  • PHP ^7.1 || ^8.0
  • PHP extensions:
    • FileInfo
  • Packages:
    • psr/log

Usage

Example

You can send simply the like this:, (*4)

use Berlioz\Mailer\Address;
use Berlioz\Mailer\Mail;
use Berlioz\Mailer\Mailer;

$mail = (new Mail())
            ->setSubject('Test of Berlioz/Mailer')
            ->setText('Text plain of my mail')
            ->setHtml('

Html text of my mail, (*5)

') ->setFrom(new Address('sender@test.com', 'Me the sender')) ->setTo([new Address('recipient@test.com', 'The recipient')]); $mailer = new Mailer(); $mailer->send($mail);

Mail

\Berlioz\Mailer\Mail it's the object representation of a mail., (*6)

Basic

use Berlioz\Mailer\Address;
use Berlioz\Mailer\Mail;

$mail = new Mail();
$mail->setSubject('Subject of my mail')
     ->setText('Text plain of my mail')
     ->setHtml('

Html text of my mail, (*7)

') ->setFrom(new Address('sender@test.com', 'Me the sender')) ->setTo([new Address('recipient@test.com', 'The recipient')]);

Attachments

To add downloadable attachment:, (*8)

use Berlioz\Mailer\Attachment;use Berlioz\Mailer\Mail;$attachment = new Attachment('/path/of/my/file.pdf');
$mail = new Mail();
$mail->addAttachment($attachment);

To attach an attachment to HTML content:, (*9)

use Berlioz\Mailer\Attachment;use Berlioz\Mailer\Mail;$attachment = new Attachment('/path/of/my/img.jpg');
$mail = new Mail();
$mail->addAttachment($attachment);

$html = '

Html content 1, (*10)

'; $html .= '<img src="cid:' . $attachment->getId() . '">'; $html .= '

Html content 2, (*11)

'; $mail->setHtml($html);

WARNING: call $attachment->getId() method, does that the attachment will be in inline disposition. Only uses this method for inline attachments., (*12)

Transports

Defaults transports

Default transport is \Berlioz\Mailer\Transport\PhpMail uses internal mail() of PHP., (*13)

You can uses another available transport for direct communication with SMTP server: \Berlioz\Mailer\Transport\Smtp., (*14)

use Berlioz\Mailer\Mailer;
use Berlioz\Mailer\Transport\Smtp;

$smtp = new Smtp(
    'smpt.test.com',
    'user@test.com',
    'password',
    25,
    ['timeout' => 5]
);
$mailer = new Mailer();
$mailer->setTransport($smtp);
use Berlioz\Mailer\Mailer;
$mailer = new Mailer([
    'transport' => [
        'name' => 'smtp',
        'arguments' => [
            'host' => 'smpt.test.com',
            'username' => 'user@test.com',
            'password' => 'password',
            'port' => 25,
            'options' => ['timeout' => 5]
        ]
    ]
]);

Create a new transport

It's possible to create new transport for various reasons. To do that, you need to create class who implements \Berlioz\Mailer\Transport\TransportInterface interface., (*15)

The Versions

29/06 2018

dev-master

9999999-dev http://www.berlioz-framework.com

Berlioz Mailer

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Giron

29/06 2018

v1.0.0

1.0.0.0 http://www.berlioz-framework.com

Berlioz Mailer

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Giron

29/06 2018

dev-develop

dev-develop http://www.berlioz-framework.com

Berlioz Mailer

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Giron

21/12 2017

dev-feature/SparkPost

dev-feature/SparkPost http://www.berlioz-framework.com

Berlioz Mailer

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Giron