Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.03 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.03 KB

🌴 WordPress Mailer

License Travis

Small OOP wrapper around wp_mail().

Requirements

  • PHP >= 5.6

Installation

Use composer to add the package to your dependencies:

composer require palmtree/wp-mailer

Create the Mailer service, usually using a DI container:

<?php
use Palmtree\WordPress\Mailer\Mailer;

$mailer = new Mailer('[email protected]', ['[email protected]']);

Usage

<?php
use Palmtree\WordPress\Mailer\Message;

$message = new Message('[email protected]');

$message
    ->setSubject('Hello!')
    ->setBody('<p>Hey, this is an HTML email!</p>')
    ->addCc('[email protected]')
    ->addBcc('[email protected]');

$message->attach('/path/to/some/file.pdf');

if ($mailer->send($message)) {
    echo 'Sent!';
} else {
    echo 'Error sending';
}

License

Released under the MIT license