[ Index ]

PHP Cross Reference of MyBB 1.8.29

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


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