An open API service indexing awesome lists of open source software.

https://github.com/truongwp/email

Abstract class for email sending in WordPress
https://github.com/truongwp/email

email email-sender wordpress

Last synced: 2 months ago
JSON representation

Abstract class for email sending in WordPress

Awesome Lists containing this project

README

          

An abstract class for email sending in WordPress.

## Installation

Use composer to include the library:

`
composer require truongwp/email="*"
`

## Usage

```php
/**
* Class ExampleEmail
*/
class ExampleEmail extends Truongwp\Email {

/**
* Whether to use HTML in email.
*
* @var bool
*/
protected $html = true;

/**
* Gets email subject.
*
* @return string
*/
protected function subject() {
return 'Example email subject';
}

/**
* Gets email content body.
*
* @return string
*/
protected function content_body() {
return '

Hi %%customer_name%%.
This is an example email from %%site_name%%

';
}

/**
* Gets email content footer.
*
* @return string
*/
protected function content_footer() {
if ( $this->html ) {
return '

Best Regards,
Truongwp

';
}

return "Best Regards,\nTruongwp";
}

/**
* Gets css for email content.
*
* @return string
*/
protected function content_css() {
return '.red { color: red; }';
}
}

$email = new ExampleEmail();
$email->replace( '%%customer_name%%', 'Truong' );
$email->send( 'truongwp@gmail.com' );
```