PHPMailer Fehler : Cannot redeclare...

phpmailer cannot redeclareHat man in der aktuellen Drupal Version 6.17 für die Module Messaging und PHPmailer dieDateien class.phpmailer.php, class.pop3.php und class.smtp.php ins jeweilige phpmailer Verzeichnis entpackt (Download: http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/ ) so findet Drupal nur 1 dieser phpmailer-Ordner und wirft im Statusreport eine Fehlermeldung für den zweiten aus:

 

Hat man zusätzlich im Ordner sites/all/libraries/ ebenfalls diesen phpmailer-Ordner (was grundsätzlich keine schlechte Idee ist, da dadurch alle Module auf diese library zugreifen können) erhält man im Browser eine "Cannot redeclare..." Fehlermeldung. Dies kann man folgendermassen lösen:

 

In der Datei messaging/messaging_phpmailer/messaging_phpmailer.module wird folgender Part ab Line 122 auskommentiert um keine doppelte phpmailer_load_library Funktion zu nutzen (was diese Fehlermeldung erzeugt):

 

function messaging_phpmailer_load_library() {
  if (!class_exists('PHPMailer')) {
    // First, try using libraries module.
    if (module_exists('libraries')) {
      // Let's see if PHPMailer is really available from libraries.
      $phpmailer_library = './'. libraries_get_path('phpmailer') .'/class.phpmailer.php';
      if (file_exists($phpmailer_library)) {
        include_once $phpmailer_library;
      }
    }
    // If PHPMailer is not already loaded, then try from module subdirectory.
    if (!class_exists('PHPMailer')) {
      $phpmailer_library = './'. drupal_get_path('module', 'messaging_phpmailer') .'/PHPMailer/class.phpmailer.php';
      if (file_exists($phpmailer_library)) {
        include_once $phpmailer_library;
      }
    }
  }
  // Tell the caller if PHPMailer class exists.
  return class_exists('PHPMailer');
}

 

und in der Datei messaging/messaging_phpmailer/messaging_phpmailer.install wird folgender Part ab Line 35 auskommentiert:

 

if (!messaging_phpmailer_load_library()) {
      $requirements['messaging_html_mail'] = array(
        'title' => $t('Messaging PHPMailer'),
        'value' => $t('PHP Mailer missing'),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('HTML Mail requires the <a href="http://phpmailer.codeworxtech.com/">PHP Mailer</a> class to properly send HTML Mail. Please download the 2.0 version and place the phpmailer folder in your messaging_phpmailer module directory. Rename the folder to "PHPMailer".'),
      );
    }

 

Jetzt können alle 3 phpmailer-Ordner dort bleiben wo sie sind und Drupal ist zufrieden ;)

Termine

« September 2010 »
MoDiMiDoFrSaSo
12345
6789101112
13141516171819
20212223242526
27282930