Skip to content

Small OOP wrapper around WordPress' wp_mail function

License

Notifications You must be signed in to change notification settings

palmtreephp/wp-mailer

Repository files navigation

🌴 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

About

Small OOP wrapper around WordPress' wp_mail function

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages