You are here

function phpmailer_requirements in PHPMailer 6.2

Same name and namespace in other branches
  1. 8.3 phpmailer.install \phpmailer_requirements()
  2. 5.2 phpmailer.install \phpmailer_requirements()
  3. 6.3 phpmailer.install \phpmailer_requirements()
  4. 7.4 phpmailer.install \phpmailer_requirements()
  5. 7.3 phpmailer.install \phpmailer_requirements()

Implementation of hook_requirements().

File

./phpmailer.install, line 11
PHPMailer installation functions.

Code

function phpmailer_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  $path = drupal_get_path('module', 'phpmailer');
  if (!file_exists('./' . $path . '/phpmailer/class.phpmailer.php') || !file_exists('./' . $path . '/phpmailer/class.smtp.php')) {
    $requirements['phpmailer'] = array(
      'title' => $t('PHPMailer library'),
      'value' => $t('Missing'),
      'severity' => REQUIREMENT_ERROR,
      'description' => $t('Please download <a href="@url">PHPMailer for PHP5/6</a>, extract the archive and copy the contents to the following location:<br /><code>@path</code>. Make sure the main file, class.phpmailer.php, is located at<br /><code>@class</code>.', array(
        '@url' => 'http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/',
        '@path' => $path . '/phpmailer/',
        '@class' => $path . '/phpmailer/class.phpmailer.php',
      )),
    );
  }
  else {
    if ($phase == 'runtime') {
      if (!class_exists('PHPMailer')) {
        module_load_include('php', 'phpmailer', 'phpmailer/class.phpmailer');
      }
      $mail = new PHPMailer();
      $requirements['phpmailer'] = array(
        'title' => $t('PHPMailer library'),
        'value' => $mail->Version,
        'severity' => REQUIREMENT_OK,
      );
    }
  }
  return $requirements;
}