<?php
  /**
   * Mailer Class
   *
   * @package Digital Downloads Pro
   * @author wojoscripts.com
   * @copyright 2010
   * @version $Id: class_mailer.php, v2.00 2011-07-10 10:12:05 gewa Exp $
   */
  
  if (!defined("_VALID_PHP"))
      die('. دسترسی مستقیم به این محل مجاز نمی باشد');

  class Mailer
  {
	  
      private $mailer;
      private $smtp_host;
      private $smtp_user;
      private $smtp_pass;
      private $smtp_port;
	  
	  
      /**
       * Mailer::__construct()
       * 
       * @return
       */
      function __construct()
      {
          global $core;
          
          $this->mailer = $core->mailer;
          $this->smtp_host = $core->smtp_host;
          $this->smtp_user = $core->smtp_user;
          $this->smtp_pass = $core->smtp_pass;
          $this->smtp_port = $core->smtp_port;
      }
	  
      /**
       * Mailer::sendMail()
       * 
	   * Sends a various messages to users
       * @return
       */
	  function sendMail()
	  {
		  require_once(BASEPATH . 'lib/swift/swift_required.php');
		  
          if ($this->mailer == "SMTP") {
              $transport = Swift_SmtpTransport::newInstance($this->smtp_host, $this->smtp_port)
						  ->setUsername($this->smtp_user)
						  ->setPassword($this->smtp_pass);
          } else
              $transport = Swift_MailTransport::newInstance();
          
          return Swift_Mailer::newInstance($transport);
	  }
	  
  }
  $mail = new Mailer();
?>