Index: messaging_phpmailer/messaging_phpmailer.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/messaging/messaging_phpmailer/Attic/messaging_phpmailer.install,v
retrieving revision 1.1.2.1.2.2.2.1
diff -u -w -b -p -r1.1.2.1.2.2.2.1 messaging_phpmailer.install
--- messaging_phpmailer/messaging_phpmailer.install	10 Jun 2009 19:54:35 -0000	1.1.2.1.2.2.2.1
+++ messaging_phpmailer/messaging_phpmailer.install	23 Sep 2009 23:16:17 -0000
@@ -30,9 +30,9 @@ function messaging_phpmailer_requirement
   $t = get_t();
 
   if ($phase == 'runtime') {
-    $path = drupal_get_path('module', 'messaging_phpmailer') .'/PHPMailer';
+    drupal_load('module', 'messaging_phpmailer');
 
-    if (!file_exists($path .'/class.phpmailer.php')) {
+    if (!messaging_phpmailer_load_library()) {
       $requirements['messaging_html_mail'] = array(
         'title' => $t('Messaging PHPMailer'),
         'value' => $t('PHP Mailer missing'),
Index: messaging_phpmailer/messaging_phpmailer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/messaging/messaging_phpmailer/Attic/messaging_phpmailer.module,v
retrieving revision 1.1.2.10.2.13.2.4
diff -u -w -b -p -r1.1.2.10.2.13.2.4 messaging_phpmailer.module
--- messaging_phpmailer/messaging_phpmailer.module	13 Jun 2009 14:49:13 -0000	1.1.2.10.2.13.2.4
+++ messaging_phpmailer/messaging_phpmailer.module	23 Sep 2009 23:21:17 -0000
@@ -114,12 +114,43 @@ function messaging_phpmailer_send_msg($d
 }
 
 /**
+ * Load the PHPMailer library.
+ *
+ * @return
+ *   TRUE if the PHPMailer library is loaded, FALSE otherwise.
+ */
+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');
+}
+
+/**
  * Send a message via PHPMailer.
  * This function mimics drupal_mail. We do not use drupal_mail instead because we want
  * to be able to send mail with both PHPMailer and MIMEMail.
  */
 function messaging_phpmailer_drupal_mail($message) {
-  include_once './'. drupal_get_path('module', 'messaging_phpmailer') .'/PHPMailer/class.phpmailer.php';
+  if (!messaging_phpmailer_load_library()) {
+    watchdog('messaging', 'Could not locate PHPMailer library.', array(), WATCHDOG_ERROR);
+    return FALSE;
+  }
   $mail = new PHPMailer();
   $mail->IsSMTP(); // telling the class to use SMTP
   $mail->CharSet = 'utf-8';
