PHP code example of wpscholar / wp-email

1. Go to this page and download the library: Download wpscholar/wp-email library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wpscholar / wp-email example snippets







use wpscholar\WordPress\Email;

// Create new email instance
$email = new Email();

// Set subject and message
$email->subject = 'Welcome!';
$email->message = '<p>Lorem ipsum dolor sit amet...</p>';

// Customize the from name and email
$email->from( 'John Doe <[email protected]>' );

// Add any recipients
$email->addRecipient( 'Jane Doe <[email protected]>' );
$email->addCcRecipient( 'James Doe <[email protected]>' );
$email->addBccRecipient( 'Super Spy <[email protected]>' );

// Add any attachments
$email->addAttachment( '/wp-content/uploads/attachment.pdf' );

// Send email
$email->send();



use wpscholar\WordPress\Email;

$email = new Email( [
	'subject'     => 'Welcome!',
	'message'     => '<p>Lorem ipsum dolor sit amet...</p>',
	'from'        => 'John Doe <[email protected]>',
	'to'          => [ 'Jane Doe <[email protected]>' ],
	'cc'          => [ 'James Doe <[email protected]>' ],
	'bcc'         => [ 'Super Spy <[email protected]>' ],
	'attachments' => [ '/wp-content/uploads/attachment.pdf' ],
] );

$email->send();