. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * This class manages the mail settings */ class NotificationMailingSetting extends NotificationSetting { static public function getTypeName($nb = 0) { return __('Email followups configuration'); } public function getEnableLabel() { return __('Enable followups via email'); } static public function getMode() { return Notification_NotificationTemplate::MODE_MAIL; } function showFormConfig($options = []) { global $CFG_GLPI; if (!isset($options['display'])) { $options['display'] = true; } $out = "
"; $out .= "
"; $out .= ""; $out .= ""; $out .= ""; if ($CFG_GLPI['notifications_mailing']) { $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $attachrand = mt_rand(); $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $methodrand = mt_rand(); $out .= ""; unset($mail_methods[MAIL_MAIL]); } $out .= Dropdown::showFromArray( "smtp_mode", $mail_methods, [ 'value' => $CFG_GLPI["smtp_mode"], 'display' => false, 'rand' => $methodrand ] ); $out .= Html::scriptBlock("$(function() { console.log($('[name=smtp_mode]')); $('[name=smtp_mode]').on('change', function() { var _val = $(this).find('option:selected').val(); if (_val == '" . MAIL_MAIL . "') { $('#smtp_config').addClass('starthidden'); } else { $('#smtp_config').removeClass('starthidden'); } }); });"); $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= "
"._n('Email notification', 'Email notifications', Session::getPluralNumber())."
"; if (!NotificationMailing::isUserAddressValid($CFG_GLPI["admin_email"])) { $out .= "
 ".__('Invalid email address').""; } $out .= "
"; $out .= "
"; if (!empty($CFG_GLPI['from_email']) &&!NotificationMailing::isUserAddressValid($CFG_GLPI["from_email"])) { $out .= "
 ".__('Invalid email address').""; } $out .= "
"; $out .= "
"; if (!empty($CFG_GLPI['admin_reply']) && !NotificationMailing::isUserAddressValid($CFG_GLPI["admin_reply"])) { $out .= "
 ".__('Invalid email address').""; } $out .= "
"; $out .= "
"; if (!empty($CFG_GLPI['admin_email_noreply']) && !NotificationMailing::isUserAddressValid($CFG_GLPI["admin_email_noreply"])) { $out .= "
 ".__('Invalid email address').""; } $out .= "
"; $out .= "
"; $out .= Dropdown::showYesNo( "attach_ticket_documents_to_mail", $CFG_GLPI["attach_ticket_documents_to_mail"], -1, ['display' => false, 'rand' => $attachrand] ); $out .= "
"; $mail_methods = [MAIL_MAIL => __('PHP'), MAIL_SMTP => __('SMTP'), MAIL_SMTPSSL => __('SMTP+SSL'), MAIL_SMTPTLS => __('SMTP+TLS')]; if (!function_exists('mail')) { $out .= "
"; $out .= "" . __('The PHP mail function is unknown or is not activated on your system.') . "
". __('The use of a SMTP is needed.') . "
"; $out .= Dropdown::showNumber('smtp_retry_time', [ 'value' => $CFG_GLPI["smtp_retry_time"], 'min' => 0, 'max' => 60, 'step' => 1, 'display' => false, ]); $out .= "
"; $out .= ""; $out .= ""; $out .= ""; $certrand = mt_rand(); $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; //TRANS: SMTP port $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= "
".AuthMail::getTypeName(1)."
"; $out .= Dropdown::showYesNo( 'smtp_check_certificate', $CFG_GLPI["smtp_check_certificate"], -1, ['display' => false, 'rand' => $certrand] ); $out .= "
"; $out.= ""; $out .= "
"; $out .= "
 "; $out .= "
"; } else { $out .= "" . __('Notifications are disabled.') . "" . __('See configuration').""; $out .= ""; } $options['candel'] = false; if ($CFG_GLPI['notifications_mailing']) { $options['addbuttons'] = ['test_smtp_send' => __('Send a test email to the administrator')]; } //do not satisfy display param since showFormButtons() will not :( echo $out; $this->showFormButtons($options); } }