Guest User

Untitled

a guest
Apr 21st, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2.  
  3.   if (!defined("_VALID_PHP"))
  4.       die('Direct access to this location is not allowed.');
  5.  
  6.   class Mailer
  7.   {
  8.      
  9.       private $mailer;
  10.       private $smtp_host;
  11.       private $smtp_user;
  12.       private $smtp_pass;
  13.       private $smtp_port;
  14.      
  15.      
  16.       /**
  17.        * Mailer::__construct()
  18.        *
  19.        * @return
  20.        */
  21.       function __construct()
  22.       {
  23.           global $core;
  24.          
  25.           $this->mailer = $core->mailer;
  26.           $this->smtp_host = $core->smtp_host;
  27.           $this->smtp_user = $core->smtp_user;
  28.           $this->smtp_pass = $core->smtp_pass;
  29.           $this->smtp_port = $core->smtp_port;
  30.       }
  31.      
  32.       /**
  33.        * Mailer::sendMail()
  34.        *
  35.        * Sends a various messages to users
  36.        * @return
  37.        */
  38.       function sendMail()
  39.       {
  40.           require_once(BASEPATH . 'lib/swift/swift_required.php');
  41.          
  42.           if ($this->mailer == "SMTP") {
  43.               $transport = Swift_SmtpTransport::newInstance($this->smtp_host, $this->smtp_port)
  44.                           ->setUsername($this->smtp_user)
  45.                           ->setPassword($this->smtp_pass);
  46.           } else
  47.               $transport = Swift_MailTransport::newInstance();
  48.          
  49.           return Swift_Mailer::newInstance($transport);
  50.       }
  51.      
  52.   }
  53.   $mail = new Mailer();
  54. ?>
Add Comment
Please, Sign In to add comment