[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

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

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id: php.php 5828 2012-05-08 16:06:16Z Tomm $
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  /**
  19   * PHP mail handler class.
  20   */
  21  class PhpMail extends MailHandler
  22  {
  23      /**
  24       * Additional parameters to pass to PHPs mail() function.
  25       *
  26       * @var string
  27      */
  28      public $additional_parameters = '';
  29  
  30      /**
  31       * Sends the email.
  32       *
  33       * @return true/false whether or not the email got sent or not.
  34       */    
  35  	function send()
  36      {
  37          global $lang, $mybb;
  38  
  39          // For some reason sendmail/qmail doesn't like \r\n
  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          // Some mail providers ignore email's with incorrect return-to path's so try and fix that here
  49          $this->sendmail_from = @ini_get('sendmail_from');
  50          if($this->sendmail_from != $mybb->settings['adminemail'])
  51          {
  52              @ini_set("sendmail_from", $mybb->settings['adminemail']);
  53          }
  54  
  55          // If safe mode is on, don't send the additional parameters as we're not allowed to
  56          if(ini_get('safe_mode') == 1 || strtolower(ini_get('safe_mode')) == 'on')
  57          {
  58              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers));
  59          }
  60          else
  61          {
  62              $sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters);
  63          }
  64          $function_used = 'mail()';
  65  
  66          if(!$sent)
  67          {
  68              $this->fatal_error("MyBB was unable to send the email using the PHP {$function_used} function.");
  69              return false;
  70          }
  71  
  72          return true;
  73      }
  74  }
  75  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1