├── .gitignore ├── LICENSE ├── README.md └── class-sendmail.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | wp-config.php 3 | wp-content/advanced-cache.php 4 | wp-content/backup-db/ 5 | wp-content/backups/ 6 | wp-content/blogs.dir/ 7 | wp-content/cache/ 8 | wp-content/upgrade/ 9 | wp-content/uploads/ 10 | wp-content/wp-cache-config.php 11 | wp-content/plugins/hello.php 12 | 13 | /.htaccess 14 | /license.txt 15 | /readme.html 16 | /sitemap.xml 17 | /sitemap.xml.gz 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 agilworld 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WP Simple Send Email Class # 2 | Simple Send Email Library Class for WordPress 3 | 4 | Just do like these : 5 | 6 | $sendmail = new Sendmail(); 7 | $sendmail->_from_name = 'Agil'; 8 | $sendmail->_from_address = 'helloworld@mail.com'; 9 | 10 | // Let's go send email 11 | $sendmail->send( 'email_destination', 'subject_email', 'emal_content' ); 12 | -------------------------------------------------------------------------------- /class-sendmail.php: -------------------------------------------------------------------------------- 1 | 7 | * @since 1.0 8 | * @license http://opensource.org/licenses/MIT MIT License 9 | * @copyright 2016 10 | */ 11 | 12 | class Sendmail { 13 | 14 | /** @var String set from name */ 15 | public $_from_name; 16 | 17 | /** @var String set from email address */ 18 | public $_from_address; 19 | 20 | public function __construct(){} 21 | 22 | /** Get from name */ 23 | public function get_from_name() { 24 | return $this->_from_name; 25 | } 26 | 27 | /** Get from e-mail address */ 28 | public function get_from_address() { 29 | return $this->_from_address; 30 | } 31 | 32 | /** Get content type text/html or text */ 33 | public function get_content_type() { 34 | return 'text/html'; 35 | } 36 | 37 | /** Let's go send email procedure */ 38 | public function send( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) { 39 | 40 | // Hook filter 41 | add_filter( 'wp_mail_from', array($this, 'get_from_address') ); 42 | add_filter( 'wp_mail_from_name', array($this, 'get_from_name') ); 43 | add_filter( 'wp_mail_content_type', array($this, 'get_content_type') ); 44 | 45 | ob_start(); 46 | 47 | wp_mail( $to, $subject, $message, $headers, $attachments ); 48 | 49 | ob_end_clean(); 50 | 51 | // Unhook 52 | remove_filter( 'wp_mail_from', array($this, 'get_from_address') ); 53 | remove_filter( 'wp_mail_from_name', array($this, 'get_from_name') ); 54 | remove_filter( 'wp_mail_content_type', array($this, 'get_content_type') ); 55 | } 56 | } 57 | --------------------------------------------------------------------------------