Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/PHPMailer.php";
- require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/Exception.php";
- require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/SMTP.php";
- class Mail {
- // Class variables
- public $charSet = "UTF-8";
- public $host = "ssl://smtp.gmail.com";
- public $SMTPDebug = 0;
- public $Port = 465;
- public $SMTPSecure = 'ssl';
- public $SMTPAuth = true;
- public $username = "andygaspard003@gmail.com";
- public $password = "Aegis4869";
- public $subject = "Library System: Notification";
- public $body;
- public $PHPMailer;
- // Constructor method
- public function __construct()
- {
- $PHPMailer = new PHPMailer\PHPMailer\PHPMailer();
- }
- // Is SMTP method
- public function isSMTP() {
- $PHPMailer->Mailer = 'mail';
- }
- // Is HTML method
- public function isHTML($isHTML = true) {
- if ($isHTML) {
- $PHPMailer->ContentType = static::CONTENT_TYPE_TEXT_HTML;
- } else {
- $PHPMailer->ContentType = static::CONTENT_TYPE_PLAINTEXT;
- }
- }
- // Set From method
- public function setFrom($address, $name = '', $auto = true) {
- $address = trim($address);
- $name = trim(preg_replace('/[\r\n]+/', '', $name));
- $pos = strrpos($address, '@');
- if ((false === $pos) || ((!$PHPMailer->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) && !static::validateAddress($address))) {
- $errorMessage = sprintf('%s (From): %s', $PHPMailer->lang('invalid_address'), $address);
- $PHPMailer->setError($errorMessage);
- $PHPMailer->edebug($errorMessage);
- if ($PHPMailer->exceptions) {
- throw new Exeception($errorMessage);
- }
- return false;
- }
- $PHPMailer->From = $address;
- $PHPMailer->FromName = $name;
- if ($auto && empty($PHPMailer->Sender)) {
- $PHPMailer->Sender = $address;
- }
- return true;
- }
- // Add Address method
- public function addAddress($address, $name = '') {
- return $PHPMailer->addOrEnqueueAnAddress('to', $address, $name);
- }
- // Send method
- public function send() {
- try {
- if (!$PHPMailer->preSend()) {
- return false;
- }
- return $PHPMailer->postSend();
- } catch (Exeception $exc) {
- $PHPMailer->mailHeader = '';
- $PHPMailer->setError($exc->getMessage());
- if ($PHPMailer->exceptions) {
- throw $exc;
- }
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement