Small OOP wrapper around wp_mail()
.
- PHP >= 5.6
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]']);
<?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';
}
Released under the MIT license