diff -rupN includes/phpmailer.class.inc includes/phpmailer.class.inc --- includes/phpmailer.class.inc 2009-11-04 21:14:50.000000000 +0100 +++ includes/phpmailer.class.inc 2009-11-05 11:38:25.000000000 +0100 @@ -6,8 +6,6 @@ * Implements the base PHPMailer for Drupal class. */ -module_load_include('php', 'phpmailer', 'phpmailer/class.phpmailer'); - /** * Base PHPMailer for Drupal implementation with support for SMTP keep-alive * and setting a custom Return-Path. diff -rupN includes/phpmailer.drupal.inc includes/phpmailer.drupal.inc --- includes/phpmailer.drupal.inc 2009-11-04 21:29:08.000000000 +0100 +++ includes/phpmailer.drupal.inc 2009-11-05 11:39:36.000000000 +0100 @@ -6,8 +6,6 @@ * Implements PHPMailer support on behalf of Drupal core. */ -module_load_include('inc', 'phpmailer', 'includes/phpmailer.class'); - /** * Send out an e-mail. * @@ -18,6 +16,10 @@ function phpmailer_send($message) { static $mail; if (!isset($mail)) { + if (!phpmailer_load_library()) { + watchdog('phpmailer', 'Could not load PHPMailer library.', NULL, WATCHDOG_ERROR); + return FALSE; + } $mail = new DrupalPHPMailer(); } diff -rupN includes/phpmailer.mimemail.inc includes/phpmailer.mimemail.inc --- includes/phpmailer.mimemail.inc 2009-11-04 20:33:24.000000000 +0100 +++ includes/phpmailer.mimemail.inc 2009-11-05 11:40:24.000000000 +0100 @@ -6,8 +6,6 @@ * Implements PHPMailer support on behalf of Mime Mail module. */ -module_load_include('inc', 'phpmailer', 'includes/phpmailer.class'); - /** * Send out an e-mail. * @@ -18,6 +16,10 @@ function mimemail_phpmailer_send($messag static $mail; if (!isset($mail)) { + if (!phpmailer_load_library()) { + watchdog('phpmailer', 'Could not load PHPMailer library.', NULL, WATCHDOG_ERROR); + return FALSE; + } $mail = new DrupalPHPMailer(); // Keep linefeed style in sync. $mail->LE = variable_get('mimemail_crlf', "\n"); diff -rupN phpmailer.info phpmailer.info --- phpmailer.info 2009-11-05 01:17:23.000000000 +0100 +++ phpmailer.info 2009-11-05 11:34:36.000000000 +0100 @@ -1,6 +1,7 @@ ; $Id: phpmailer.info,v 1.4 2009/11/04 19:37:13 smk Exp $ name = PHPMailer description = Integrates the PHPMailer library for e-mail delivery. +dependencies[] = libraries package = Mail core = 6.x ; Information added by drupal.org packaging script on 2009-11-05 diff -rupN phpmailer.install phpmailer.install --- phpmailer.install 2009-11-04 17:47:51.000000000 +0100 +++ phpmailer.install 2009-11-05 11:47:18.000000000 +0100 @@ -14,20 +14,19 @@ function phpmailer_requirements($phase) // 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')) { + $path = libraries_get_path('phpmailer'); + if (!file_exists('./' . $path . '/class.phpmailer.php') || !file_exists('./' . $path . '/class.smtp.php')) { $requirements['phpmailer'] = array( 'title' => $t('PHPMailer library'), 'severity' => REQUIREMENT_ERROR, 'description' => $t('PHPMailer module requires the PHPMailer library to properly send mail. Please download the PHPMailer package for PHP5/6, extract the archive and copy its contents to the following location: @phpmailer-path. Make sure the main PHPMailer class is located at @phpmailer-class-path.', array( '@phpmailer-url' => 'http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/', - '@phpmailer-path' => $path . '/phpmailer/', - '@phpmailer-class-path' => $path . '/phpmailer/class.phpmailer.php', + '@phpmailer-path' => $path, + '@phpmailer-class-path' => $path . '/class.phpmailer.php', )), ); } else if ($phase == 'runtime') { - module_load_include('php', 'phpmailer', 'phpmailer/class.phpmailer'); $mail = new PHPMailer(); $requirements['phpmailer'] = array( 'title' => $t('PHPMailer library'), @@ -54,4 +53,3 @@ function phpmailer_uninstall() { variable_del('smtp_keepalive'); variable_del('smtp_debug'); } - diff -rupN phpmailer.module phpmailer.module --- phpmailer.module 2009-11-04 20:19:32.000000000 +0100 +++ phpmailer.module 2009-11-05 11:37:55.000000000 +0100 @@ -156,3 +156,24 @@ function phpmailer_disable() { } } +/** + * Load PHPMailer class from libraries path. + */ +function phpmailer_load_library() { + if (!class_exists('PHPMailer')) { + $phpmailer_library = './'. libraries_get_path('phpmailer') .'/class.phpmailer.php'; + if (!file_exists($phpmailer_library)) { + // Provide backwards compatibility for existing installations of + // PHPMailer module. + $phpmailer_library = './'. drupal_get_path('module', 'phpmailer') .'/phpmailer/class.phpmailer.php'; + if (!file_exists($phpmailer_library)) { + return FALSE; + } + } + require_once $phpmailer_library; + } + if (!class_exits('DrupalPHPMailer')) { + module_load_include('inc', 'phpmailer', 'includes/phpmailer.class'); + } + return TRUE; +} diff -rupN README.txt README.txt --- README.txt 2009-10-12 21:44:43.000000000 +0200 +++ README.txt 2009-11-05 11:34:19.000000000 +0100 @@ -14,6 +14,9 @@ To submit bug reports and feature sugges * Access to an SMTP server +* Libraries API module + http://drupal.org/project/libraries + * PHPMailer for PHP5/6 http://phpmailer.codeworxtech.com @@ -35,14 +38,22 @@ Optional: http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/ - and extract the the following files to the subdirectory 'phpmailer' of this - module: + and extract the following files to the phpmailer subdirectory of your + libraries directory: class.phpmailer.php class.smtp.php - + Be careful NOT to extract the path names contained in the archive. + You can create your libraries directory to any of the following locations: + + profiles/profile/libraries + sites/all/libraries + sites//libraries + + Please, consult the Libraries API documentation for further information. + 2. Install as usual, see http://drupal.org/node/70151 for further information.