Posted by kyle_mathews on September 22, 2010 at 11:03pm
2 followers
Jump to:
| Project: | SMTP Authentication Support |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
Which if it is, this error is thrown:
Fatal error: Cannot redeclare class phpmailerException in /home/path/to/website/sites/all/modules/smtp/phpmailer/class.phpmailer.php on line 2319To fix this, just change around line 266 to look like the following:
<?php
// Include the PHPMailer class (which includes the SMTP class).
if (!class_exists('PHPMailer')) {
require_once(drupal_get_path('module', 'smtp') .'/phpmailer/class.phpmailer.php');
}
?>
Comments
#1
--- IGNORE -- Pasted wrong function.
#2
I'd also suggest adding a phpmailer_load function which can check in the libraries directory as well as in a subdirectory. This is a function I wrote for OG Mailinglist, borrowed mostly untouched from messaging_phpmailer.
<?phpfunction og_mailinglist_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', 'og_mailinglist') .'/PHPMailer/class.phpmailer.php';
if (file_exists($phpmailer_library)) {
include_once $phpmailer_library;
}
}
}
// Tell the caller if PHPMailer class exists.
return class_exists('PHPMailer');
}
?>
#3
I think it's a duplicate of #541942: Move PHPMailer out of the module folder, check for class already defined. As there is a patch on that issue, I'm closing this one.