You are here

function smtp_load_library in SMTP Authentication Support 6

Load the PHPMailer library.

Return value

TRUE if the PHPMailer library is loaded, FALSE otherwise.

2 calls to smtp_load_library()
smtp_drupal_mail_wrapper in ./smtp.module
Sends out the e-mail.
smtp_requirements in ./smtp.module
Check for the required 3rd party libaries

File

./smtp.module, line 292
Enables Drupal to send e-mail directly to an SMTP server.

Code

function smtp_load_library() {

  // Include the PHPMailer class (which includes the SMTP class).
  if (!class_exists('PHPMailer')) {

    // First try using the libraries module.
    if (module_exists('libraries')) {
      $smtp_phpmailer_library = module_invoke('libraries', 'get_path', 'phpmailer') . '/class.phpmailer.php';
    }
    else {

      //Look in the default libraries location
      $smtp_phpmailer_library = 'sites/all/libraries/phpmailer/class.phpmailer.php';

      //If the default libraries doesn't exist, then try the old module location.
      if (!file_exists($smtp_phpmailer_library)) {
        $smtp_phpmailer_library = drupal_get_path('module', 'smtp') . '/phpmailer/class.phpmailer.php';
      }
    }

    //Now include whatever you found.
    if (file_exists($smtp_phpmailer_library)) {
      require_once $smtp_phpmailer_library;
    }
  }

  // Tell the caller if PHPMailer class exists.
  return class_exists('PHPMailer');
}