[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/inc/mailhandlers/ -> php.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  /**
  18   * PHP mail handler class.
  19   */
  20  class PhpMail extends MailHandler
  21  {
  22      /**
  23       * Additional parameters to pass to PHPs mail() function.
  24       *
  25       * @var string
  26      */
  27      public $additional_parameters = '';
  28  
  29      /**
  30       * Path where the sendmail program can be found.
  31       *
  32       * @var string
  33       */
  34      public $sendmail = '';
  35  
  36      /**
  37       * Which "From:" mail address should be used in mail sent directly via SMTP.
  38       *
  39       * @var string
  40       */
  41      public $sendmail_from = '';
  42  
  43      /**
  44       * Sends the email.
  45       *
  46       * @return bool whether or not the email got sent or not.
  47       */
  48  	function send()
  49      {
  50          global $lang, $mybb;
  51  
  52          // For some reason sendmail/qmail doesn't like \r\n
  53          /*
  54          $this->sendmail = @ini_get('sendmail_path');
  55          if($this->sendmail)
  56          {
  57              $this->headers = str_replace("\r\n", "\n", $this->headers);
  58              $this->message = str_replace("\r\n", "\n", $this->message);
  59              $this->delimiter = "\n";
  60          }
  61          */
  62  
  63          // Some mail providers ignore email's with incorrect return-to path's so try and fix that here
  64          $this->sendmail_from = @ini_get('sendmail_from');
  65          if($this->sendmail_from != $mybb->settings['adminemail'])
  66          {
  67              @ini_set("sendmail_from", $mybb->settings['adminemail']);
  68          }
  69  
  70          $dir = "/{$mybb->config['admin_dir']}/";
  71          $pos = strrpos($_SERVER['PHP_SELF'], $dir);
  72          if(defined('IN_ADMINCP') && $pos !== false)
  73          {
  74              $temp_script_path = $_SERVER['PHP_SELF'];
  75              $_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], $pos + strlen($dir) - 1);
  76          }
  77  
  78          // If safe mode is on, don't send the additional parameters as we're not allowed to
  79          if($mybb->safemode)
  80          {
  81              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers));
  82          }
  83          else
  84          {
  85              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters);
  86          }
  87          $function_used = 'mail()';
  88  
  89          if(defined('IN_ADMINCP') && $pos !== false)
  90          {
  91              $_SERVER['PHP_SELF'] = $temp_script_path;
  92          }
  93  
  94          if(!$sent)
  95          {
  96              $this->fatal_error("MyBB was unable to send the email using the PHP {$function_used} function.");
  97              return false;
  98          }
  99  
 100          return true;
 101      }
 102  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref