palmtree/wp-mailer

WordPress mailer

v1.0.0 2019-03-04 20:57 UTC

This package is auto-updated.

Last update: 2024-12-05 19:11:33 UTC


README

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('website@example.org', ['bcc@example.org']);

Usage

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

$message = new Message('to@example.org');

$message
    ->setSubject('Hello!')
    ->setBody('<p>Hey, this is an HTML email!</p>')
    ->addCc('cc@example.org')
    ->addBcc('anotherbcc@example.org');

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

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

License

Released under the MIT license