dev-master
9999999-devA WordPress library to simplify sending emails.
GPL-2.0+ GPL-2.0-or-later
by Micah Wood
Wallogit.com
2017 © Pedro Peláez
A WordPress library to simplify sending emails.
A WordPress library to simplify sending emails., (*1)
While WordPress does have the wp_mail() function, there are still a number of things you have to be aware of when sending emails. For example:, (*2)
This library removes these concerns and makes it easy to setup and send emails without impacting other emails being sent from the system., (*3)
$ composer require wpscholar/wp-email
<?php require __DIR__ . '/vendor/autoload.php';
<?php use wpscholar\WordPress\Email; // Create new email instance $email = new Email(); // Set subject and message $email->subject = 'Welcome!'; $email->message = 'Lorem ipsum dolor sit amet..., (*4)
'; // Customize the from name and email $email->from( 'John Doe <john@email.com>' ); // Add any recipients $email->addRecipient( 'Jane Doe <jane@email.com>' ); $email->addCcRecipient( 'James Doe <james@email.com>' ); $email->addBccRecipient( 'Super Spy <topsecret@email.com>' ); // Add any attachments $email->addAttachment( '/wp-content/uploads/attachment.pdf' ); // Send email $email->send();
OR, (*5)
<?php
use wpscholar\WordPress\Email;
$email = new Email( [
'subject' => 'Welcome!',
'message' => '
Lorem ipsum dolor sit amet..., (*6)
',
'from' => 'John Doe <john@email.com>',
'to' => [ 'Jane Doe <jane@email.com>' ],
'cc' => [ 'James Doe <james@email.com>' ],
'bcc' => [ 'Super Spy <topsecret@email.com>' ],
'attachments' => [ '/wp-content/uploads/attachment.pdf' ],
] );
$email->send();
A WordPress library to simplify sending emails.
GPL-2.0+ GPL-2.0-or-later