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
- Host: GitHub
- URL: https://github.com/truongwp/email
- Owner: truongwp
- License: gpl-2.0
- Created: 2017-08-25T07:35:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-31T15:41:10.000Z (almost 9 years ago)
- Last Synced: 2025-07-19T16:42:16.877Z (11 months ago)
- Topics: email, email-sender, wordpress
- Language: PHP
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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' );
```