[ Index ]

PHP Cross Reference of MyBB 1.8.37

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       * Sends the email.
  31       *
  32       * @return bool whether or not the email got sent or not.
  33       */
  34  	function send()
  35      {
  36          global $lang, $mybb;
  37  
  38          // For some reason sendmail/qmail doesn't like \r\n
  39          /*
  40          $this->sendmail = @ini_get('sendmail_path');
  41          if($this->sendmail)
  42          {
  43              $this->headers = str_replace("\r\n", "\n", $this->headers);
  44              $this->message = str_replace("\r\n", "\n", $this->message);
  45              $this->delimiter = "\n";
  46          }
  47          */
  48  
  49          // Some mail providers ignore email's with incorrect return-to path's so try and fix that here
  50          $this->sendmail_from = @ini_get('sendmail_from');
  51          if($this->sendmail_from != $mybb->settings['adminemail'])
  52          {
  53              @ini_set("sendmail_from", $mybb->settings['adminemail']);
  54          }
  55  
  56          $dir = "/{$mybb->config['admin_dir']}/";
  57          $pos = strrpos($_SERVER['PHP_SELF'], $dir);
  58          if(defined('IN_ADMINCP') && $pos !== false)
  59          {
  60              $temp_script_path = $_SERVER['PHP_SELF'];
  61              $_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], $pos + strlen($dir) - 1);
  62          }
  63  
  64          // If safe mode is on, don't send the additional parameters as we're not allowed to
  65          if($mybb->safemode)
  66          {
  67              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers));
  68          }
  69          else
  70          {
  71              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters);
  72          }
  73          $function_used = 'mail()';
  74  
  75          if(defined('IN_ADMINCP') && $pos !== false)
  76          {
  77              $_SERVER['PHP_SELF'] = $temp_script_path;
  78          }
  79  
  80          if(!$sent)
  81          {
  82              $this->fatal_error("MyBB was unable to send the email using the PHP {$function_used} function.");
  83              return false;
  84          }
  85  
  86          return true;
  87      }
  88  }


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