function phpmailer_requirements in PHPMailer 8.3
Same name and namespace in other branches
- 5.2 phpmailer.install \phpmailer_requirements()
- 6.3 phpmailer.install \phpmailer_requirements()
- 6.2 phpmailer.install \phpmailer_requirements()
- 7.4 phpmailer.install \phpmailer_requirements()
- 7.3 phpmailer.install \phpmailer_requirements()
Implementation of hook_requirements().
File
- ./
phpmailer.install, line 11 - PHPMailer installation functions.
Code
function phpmailer_requirements($phase) {
$requirements = [];
if (class_exists('PHPMailer')) {
$mail = new PHPMailer();
}
if (empty($mail)) {
$requirements['phpmailer'] = [
'title' => (string) t('PHPMailer library'),
'value' => (string) t('Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => (string) t("Please install the PHPMailer library by executing 'composer update' in your site's root directory."),
];
}
else {
$required_version = '5.2.26';
$installed_version = $mail->Version;
$requirements['phpmailer'] = [
'title' => (string) t('PHPMailer library'),
'value' => $installed_version,
];
if (!version_compare($installed_version, $required_version, '>=')) {
$requirements['phpmailer']['severity'] = REQUIREMENT_ERROR;
$requirements['phpmailer']['description'] = (string) t("PHPMailer library @version or higher is required. Please install a newer version by executing 'composer update' in your site's root directory.", [
'@version' => $required_version,
]);
}
else {
$requirements['phpmailer']['severity'] = REQUIREMENT_OK;
}
}
return $requirements;
}