Skip to content

Instantly share code, notes, and snippets.

@VishalTaj
Last active November 6, 2018 02:04
Show Gist options
  • Save VishalTaj/61679443bb3d24397c75b3dfd2f7b634 to your computer and use it in GitHub Desktop.
Save VishalTaj/61679443bb3d24397c75b3dfd2f7b634 to your computer and use it in GitHub Desktop.
<?php
ini_set('display_errors', '0');
require_once "Mail.php";
require_once "Mail/mime.php";
require_once 'config.inc.php'; # you can define constants in this file.
class Mailer {
var $_headers = array();
public function __construct($subject) {
$this->_headers = array('From' => FROM_EMAIL,
'To' => implode(TO_EMAIL, ','),
'Subject' => $subject,
'MIME-Version' => 1,
'Content-type' => 'text/html;charset=iso-8859-1'
);
}
public function send_mail($body) {
$smtp = Mail::factory('smtp',
array ('host' => HOST,
'auth' => 'plain',
'port' => PORT,
'username' => USERNAME,
'password' => PASSWORD));
$mail = $smtp->send(implode(TO_EMAIL, ','), $this->_headers, $body);
if (PEAR::isError($mail)) {
return false;
} else {
return true;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment