Auto detect phpmailer version removing need to configure

This commit is contained in:
Retro_Guy 2021-02-01 02:12:25 -07:00
parent 74c02675ab
commit 88a8433f6b
2 changed files with 16 additions and 16 deletions

View File

@ -16,8 +16,12 @@ if (file_exists('../common/mods/style.css')) {
include "config.inc.php";
include($config_dir.'/phpmailer.inc.php');
# The following line is required for phpmailer 6.0 or above
#use PHPMailer\PHPMailer\PHPMailer;
// Setup mailer
if(class_exists('PHPMailer')) {
$mail = new PHPMailer();
} else {
$mail = new PHPMailer\PHPMailer\PHPMailer();
}
include "head.inc";
$CONFIG = include($config_file);
@ -142,8 +146,6 @@ if ($ok || ($command == "Create") )
}
}
if($CONFIG['verify_email']) {
// Setup mailer
$mail = new PHPMailer();
$mail->SMTPOptions = array(
'ssl' => array(

View File

@ -1,19 +1,17 @@
<?php
# Server info and credentials for sending email
# (sending mail requires PHPMailer package installed)
# PHPMailer settings (comment out the versions that do not apply)
# PHPMailer 6.0 and above:
#$phpmailer['phpmailer'] = '/usr/share/php/libphp-phpmailer/src/PHPMailer.php';
#$phpmailer['smtp'] = '/usr/share/php/libphp-phpmailer/src/SMTP.php';
# PHPMailer pre 6.0
#$phpmailer['phpmailer'] = '/usr/share/php/libphp-phpmailer/class.phpmailer.php';
#$phpmailer['smtp'] = '/usr/share/php/libphp-phpmailer/class.smtp.php';
# FreeBSD 12
$phpmailer['phpmailer'] = '/usr/local/share/phpmailer/class.phpmailer.php';
$phpmailer['smtp'] = '/usr/local/share/phpmailer/class.smtp.php';
if(is_file('/usr/share/php/libphp-phpmailer/src/PHPMailer.php')) {
$phpmailer['phpmailer'] = '/usr/share/php/libphp-phpmailer/src/PHPMailer.php';
$phpmailer['smtp'] = '/usr/share/php/libphp-phpmailer/src/SMTP.php';
} elseif(is_file('/usr/share/php/libphp-phpmailer/class.phpmailer.php')) {
$phpmailer['phpmailer'] = '/usr/share/php/libphp-phpmailer/class.phpmailer.php';
$phpmailer['smtp'] = '/usr/share/php/libphp-phpmailer/class.smtp.php';
} elseif(is_file('/usr/local/share/phpmailer/class.phpmailer.php')) {
$phpmailer['phpmailer'] = '/usr/local/share/phpmailer/class.phpmailer.php';
$phpmailer['smtp'] = '/usr/local/share/phpmailer/class.smtp.php';
}
$mailer = array();
$mailer['host'] = "mail.example.com";