/** * Override standard validation and sending notification to send the good PDF reports with * appropriate rigths. * * @see NotificationTarget::validateSendTo() * * @param string $event notification event * @param Array $infos Current user informations * @param Boolean $notify_me Notify the current user of his own actions ? * * @return boolean false to prevent standard mail sending */ function validateSendTo($event, array $infos, $notify_me = false) { global $DB; if (isset($infos['users_id'])) { // save session variables $saved_session = $_SESSION; // Get current user full informations $user = new User(); $user->getFromDB($infos['users_id']); // inialize session for user to build the proper PDF report unset($_SESSION['glpiprofiles'], $_SESSION['glpiactiveentities'], $_SESSION['glpiactiveprofile']); Session::initEntityProfiles($infos['users_id']); // Use default profile if exist if (isset($_SESSION['glpiprofiles'][$user->fields['profiles_id']])) { Session::changeProfile($user->fields['profiles_id']); // Else use first } else { Session::changeProfile(key($_SESSION['glpiprofiles'])); } $user_name = $infos['username'] . '_'; $file_name = $this->_buildPDF($user_name); $path = GLPI_PLUGIN_DOC_DIR . '/mreporting/notifications/' . $file_name; $mmail = new NotificationMail(); $mmail->AddCustomHeader("Auto-Submitted: auto-generated"); // For exchange $mmail->AddCustomHeader("X-Auto-Response-Suppress: OOF, DR, NDR, RN, NRN"); // Get current entity administrator info to send the email from him $admin = $this->getSender(); $mmail->From = $admin['email']; $mmail->FromName = $admin['name']; // Attach pdf to mail $mmail->AddAttachment($path, $file_name); // Get content infos $query = 'SELECT * FROM glpi_notificationtemplatetranslations WHERE notificationtemplates_id = ( SELECT id FROM glpi_notificationtemplates WHERE itemtype = "PluginMreportingNotification" ) AND (language LIKE "' . $_SESSION['glpilanguage'] . '" OR language LIKE "") ORDER BY language DESC LIMIT 0, 1'; $result = $DB->query($query); $translation = $result->fetch_array(); $mmail->isHTML(true); $mmail->Subject = $translation['subject']; $mmail->Body = $translation['content_html']; $mmail->AltBody = $translation['content_text']; $mmail->AddAddress($infos['email']); if ($mmail->Send()) { } //restore session unset($_SESSION); $_SESSION = $saved_session; } return false; }
function showFormMailServerConfig() { global $CFG_GLPI; echo "<form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>"; echo "<div>"; echo "<table class='tab_cadre_fixe'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . _n('Notification', 'Notifications', 2) . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Enable followup via email') . "</td><td>"; Dropdown::showYesNo("use_mailing", $CFG_GLPI["use_mailing"]); echo "</td>"; if ($CFG_GLPI['use_mailing']) { echo "<td colspan='2'></td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Administrator email') . "</td>"; echo "<td><input type='text' name='admin_email' size='40' value='" . $CFG_GLPI["admin_email"] . "'>"; if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_email"])) { echo "<span class='red'> " . __('Invalid email address') . "</span>"; } echo "</td>"; echo "<td >" . __('Administrator name') . "</td>"; echo "<td><input type='text' name='admin_email_name' size='40' value='" . $CFG_GLPI["admin_email_name"] . "'>"; echo " </td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td >" . __('Administrator reply-to email (if needed)') . "</td>"; echo "<td><input type='text' name='admin_reply' size='40' value='" . $CFG_GLPI["admin_reply"] . "'>"; if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_reply"])) { echo "<span class='red'> " . __('Invalid email address') . "</span>"; } echo " </td>"; echo "<td >" . __('Response address (if needed)') . "</td>"; echo "<td><input type='text' name='admin_reply_name' size='40' value='" . $CFG_GLPI["admin_reply_name"] . "'>"; echo " </td></tr>"; if (!function_exists('mail')) { echo "<tr class='tab_bg_2'><td class='center' colspan='2'>"; echo "<span class='red'>" . __('The PHP mail function is unknown or is not activated on your system.') . "</span><br>" . __('The use of a SMTP is needed.') . "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Email signature') . "</td>"; echo "<td colspan='3'><textarea cols='60' rows='3' name='mailing_signature'>" . $CFG_GLPI["mailing_signature"] . "</textarea></td></tr>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Mail server') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Way of sending emails') . "</td><td>"; $mail_methods = array(MAIL_MAIL => __('PHP'), MAIL_SMTP => __('SMTP'), MAIL_SMTPSSL => __('SMTP+SSL'), MAIL_SMTPTLS => __('SMTP+TLS')); Dropdown::showFromArray("smtp_mode", $mail_methods, array('value' => $CFG_GLPI["smtp_mode"])); echo "</td><td colspan='2'> </td>"; echo "</tr>"; echo "<tr class='tab_bg_2'><td >" . __('SMTP host') . "</td>"; echo "<td><input type='text' name='smtp_host' size='40' value='" . $CFG_GLPI["smtp_host"] . "'>"; echo "</td>"; echo "<td >" . __('SMTP login (optional)') . "</td>"; echo "<td><input type='text' name='smtp_username' size='40' value='" . $CFG_GLPI["smtp_username"] . "'></td></tr>"; //TRANS: SMTP port echo "<tr class='tab_bg_2'><td >" . __('Port') . "</td>"; echo "<td><input type='text' name='smtp_port' size='5' value='" . $CFG_GLPI["smtp_port"] . "'>"; echo "</td>"; echo "<td >" . __('SMTP password (optional)') . "</td>"; echo "<td><input type='password' name='smtp_passwd' size='40' value='' autocomplete='off'>"; echo "<br><input type='checkbox' name='_blank_smtp_passwd'> " . __('Clear'); echo "</td></tr>"; } else { echo "<td colspan='2'></td></tr>"; } $options['candel'] = false; if ($CFG_GLPI['use_mailing']) { $options['addbuttons'] = array('test_smtp_send' => __('Send a test email to the administrator')); } $this->showFormButtons($options); }
static function send($mailing_options) { $mail = new NotificationMail(); $mail->sendNotification($mailing_options); $mail->ClearAddresses(); }
/** * Send password recovery for a user. * * @param $email email of the user * * @return nothing : send email or display error message **/ function forgetPassword($email) { global $LANG, $CFG_GLPI; echo "<div class='center'>"; if ($this->getFromDBbyEmail($email)) { // Send token if auth DB or not external auth defined if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) { if (NotificationMail::isUserAddressValid($email)) { $input['token'] = sha1(getRandomString(30)); $input['tokendate'] = $_SESSION["glpi_currenttime"]; $input['id'] = $this->fields['id']; $this->update($input); NotificationEvent::raiseEvent('passwordforget', $this); echo $LANG['users'][10]; } else { echo $LANG['mailing'][110]; } } else { echo $LANG['users'][9]; } } else { echo $LANG['users'][8]; } echo "<br>"; echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/index.php\">" . $LANG['buttons'][13] . "</a>"; echo "</div>"; }
/** * show tooltip for user notification information * * @param $type integer user type * @param $canedit boolean can edit ? * @param $options array options for default values ($options of showForm) * * @return nothing display **/ function showUsersAssociated($type, $canedit, array $options = array()) { global $CFG_GLPI; $showuserlink = 0; if (User::canView()) { $showuserlink = 2; } $usericon = self::getActorIcon('user', $type); $user = new User(); $linkuser = new $this->userlinkclass(); $itemtype = $this->getType(); $typename = self::getActorFieldNameType($type); $candelete = true; $mandatory = ''; // For ticket templates : mandatories if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) { $mandatory = $options['_tickettemplate']->getMandatoryMark("_users_id_" . $typename); if ($options['_tickettemplate']->isMandatoryField("_users_id_" . $typename) && isset($this->users[$type]) && count($this->users[$type]) == 1) { $candelete = false; } } if (isset($this->users[$type]) && count($this->users[$type])) { foreach ($this->users[$type] as $d) { $k = $d['users_id']; echo "{$mandatory}{$usericon} "; if ($k) { $userdata = getUserName($k, 2); } else { $email = $d['alternative_email']; $userdata = "<a href='mailto:{$email}'>{$email}</a>"; } if ($k) { $param = array('display' => false); if ($showuserlink) { $param['link'] = $userdata["link"]; } echo $userdata['name'] . " " . Html::showToolTip($userdata["comment"], $param); } else { echo $userdata; } if ($CFG_GLPI['use_mailing']) { $text = __('Email followup') . " " . Dropdown::getYesNo($d['use_notification']) . '<br>'; if ($d['use_notification']) { $uemail = $d['alternative_email']; if (empty($uemail) && $user->getFromDB($d['users_id'])) { $uemail = $user->getDefaultEmail(); } $text .= sprintf(__('%1$s: %2$s'), __('Email'), $uemail); if (!NotificationMail::isUserAddressValid($uemail)) { $text .= " <span class='red'>" . __('Invalid email address') . "</span>"; } } echo " "; if ($canedit || $d['users_id'] == Session::getLoginUserID()) { $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => $linkuser->getFormURL() . "?id=" . $d['id']); Html::showToolTip($text, $opt); } } if ($canedit && $candelete) { echo " "; Html::showSimpleForm($linkuser->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png"); } echo "<br>"; } } }
/** * Print the object user form for notification * * @param $ID integer ID of the item * @param $options array * * @return Nothing (display) **/ function showUserNotificationForm($ID, $options = array()) { global $CFG_GLPI; $this->check($ID, UPDATE); if (!isset($this->fields['users_id'])) { return false; } $item = new static::$itemtype_1(); echo "<br><form method='post' action='" . $_SERVER['PHP_SELF'] . "'>"; echo "<div class='center'>"; echo "<table class='tab_cadre' width='80%'>"; echo "<tr class='tab_bg_2'><td>" . $item->getTypeName(1) . "</td>"; echo "<td>"; if ($item->getFromDB($this->fields[static::getItilObjectForeignKey()])) { echo $item->getField('name'); } echo "</td></tr>"; $user = new User(); $default_email = ""; $emails = array(); if ($user->getFromDB($this->fields["users_id"])) { $default_email = $user->getDefaultEmail(); $emails = $user->getAllEmails(); } echo "<tr class='tab_bg_2'><td>" . __('User') . "</td>"; echo "<td>" . $user->getName() . "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Email Followup') . "</td>"; echo "<td>"; Dropdown::showYesNo('use_notification', $this->fields['use_notification']); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Email') . "</td>"; echo "<td>"; if (count($emails) == 1 && !empty($default_email) && NotificationMail::isUserAddressValid($default_email)) { echo $default_email; } else { if (count($emails) > 1) { // Several emails : select in the list $emailtab = array(); foreach ($emails as $new_email) { if ($new_email != $default_email) { $emailtab[$new_email] = $new_email; } else { $emailtab[''] = $new_email; } } Dropdown::showFromArray("alternative_email", $emailtab, array('value' => $this->fields['alternative_email'])); } else { echo "<input type='text' size='40' name='alternative_email' value='" . $this->fields['alternative_email'] . "'>"; } } echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='2'>"; echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }
/** * Try to get login of external auth method * * @param $authtype external auth type (default 0) * * @return boolean : user login success **/ function getAlternateAuthSystemsUserLogin($authtype = 0) { global $CFG_GLPI; switch ($authtype) { case self::CAS: include GLPI_PHPCAS; phpCAS::client(CAS_VERSION_2_0, $CFG_GLPI["cas_host"], intval($CFG_GLPI["cas_port"]), $CFG_GLPI["cas_uri"], false); // no SSL validation for the CAS server phpCAS::setNoCasServerValidation(); // force CAS authentication phpCAS::forceAuthentication(); $this->user->fields['name'] = phpCAS::getUser(); return true; case self::EXTERNAL: $ssovariable = Dropdown::getDropdownName('glpi_ssovariables', $CFG_GLPI["ssovariables_id"]); $login_string = ''; // MoYo : checking REQUEST create a security hole for me ! if (isset($_SERVER[$ssovariable])) { $login_string = $_SERVER[$ssovariable]; } // else { // $login_string = $_REQUEST[$ssovariable]; // } $login = $login_string; $pos = stripos($login_string, "\\"); if (!$pos === false) { $login = substr($login_string, $pos + 1); } if ($CFG_GLPI['existing_auth_server_field_clean_domain']) { $pos = stripos($login, "@"); if (!$pos === false) { $login = substr($login, 0, $pos); } } if (self::isValidLogin($login)) { $this->user->fields['name'] = $login; // Get data from SSO if defined $ret = $this->user->getFromSSO(); if (!$ret) { return false; } return true; } break; case self::X509: // From eGroupWare http://www.egroupware.org // an X.509 subject looks like: // CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/ $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']); while ($sslattrib = next($sslattribs)) { list($key, $val) = explode('=', $sslattrib); $sslattributes[$key] = $val; } if (isset($sslattributes[$CFG_GLPI["x509_email_field"]]) && NotificationMail::isUserAddressValid($sslattributes[$CFG_GLPI["x509_email_field"]]) && self::isValidLogin($sslattributes[$CFG_GLPI["x509_email_field"]])) { $restrict = false; $CFG_GLPI["x509_ou_restrict"] = trim($CFG_GLPI["x509_ou_restrict"]); if (!empty($CFG_GLPI["x509_ou_restrict"])) { $split = explode('$', $CFG_GLPI["x509_ou_restrict"]); if (!in_array($sslattributes['OU'], $split)) { $restrict = true; } } $CFG_GLPI["x509_o_restrict"] = trim($CFG_GLPI["x509_o_restrict"]); if (!empty($CFG_GLPI["x509_o_restrict"])) { $split = explode('$', $CFG_GLPI["x509_o_restrict"]); if (!in_array($sslattributes['O'], $split)) { $restrict = true; } } $CFG_GLPI["x509_cn_restrict"] = trim($CFG_GLPI["x509_cn_restrict"]); if (!empty($CFG_GLPI["x509_cn_restrict"])) { $split = explode('$', $CFG_GLPI["x509_cn_restrict"]); if (!in_array($sslattributes['CN'], $split)) { $restrict = true; } } if (!$restrict) { $this->user->fields['name'] = $sslattributes[$CFG_GLPI["x509_email_field"]]; // Can do other things if need : only add it here $this->user->fields['email'] = $this->user->fields['name']; return true; } } break; } return false; }
echo __('Email followup') . ' '; $default_notif = true; if (isset($_POST['use_notification'][$user_index])) { $default_notif = $_POST['use_notification'][$user_index]; } if (isset($_POST['alternative_email'][$user_index]) && !empty($_POST['alternative_email'][$user_index]) && empty($default_email)) { if (NotificationMail::isUserAddressValid($_POST['alternative_email'][$user_index])) { $default_email = $_POST['alternative_email'][$user_index]; } else { throw new \RuntimeException('Invalid email provided!'); } } $rand = Dropdown::showYesNo($_POST['field'] . '[use_notification][]', $default_notif); $email_string = ''; // Only one email if (count($emails) == 1 && !empty($default_email) && NotificationMail::isUserAddressValid($default_email[$user_index])) { $email_string = $default_email[$user_index]; // Clean alternative email echo "<input type='hidden' size='25' name='" . $_POST['field'] . "[alternative_email][]'\n value=''>"; } else { if (count($emails) > 1) { // Several emails : select in the list $emailtab = array(); foreach ($emails as $new_email) { if ($new_email != $default_email) { $emailtab[$new_email] = $new_email; } else { $emailtab[''] = $new_email; } } $email_string = Dropdown::showFromArray($_POST['field'] . "[alternative_email][]", $emailtab, array('value' => '', 'display' => false));
// Purpose of file: // ---------------------------------------------------------------------- $AJAX_INCLUDE = 1; if (strpos($_SERVER['PHP_SELF'], "uemailUpdate.php")) { define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); } checkLoginUser(); // print_r($_REQUEST); if (isset($_REQUEST['field']) && $_REQUEST["value"] > 0 || isset($_REQUEST['allow_email']) && $_REQUEST['allow_email']) { $user = new User(); $email = ""; if ($user->getFromDB($_REQUEST["value"])) { $email = $user->getField('email'); } echo $LANG['job'][19] . ' : '; $default_notif = true; if (isset($_REQUEST['use_notification'])) { $default_notif = $_REQUEST['use_notification']; } $rand = Dropdown::showYesNo($_REQUEST['field'] . '[use_notification]', $default_notif); echo '<br>' . $LANG['mailing'][118] . " : "; if (!empty($email) && NotificationMail::isUserAddressValid($email)) { echo $email; } else { echo "<input type='text' size='25' name='" . $_REQUEST['field'] . "[alternative_email]'\n value='{$email}'>"; } } commonDropdownUpdateItem($_POST);
function getOldAssignTechnicianAddress() { global $CFG_GLPI; if (isset($this->options['_old_user']) && $this->options['_old_user']['type'] == CommonITILActor::ASSIGN && $this->options['_old_user']['use_notification']) { $user = new User(); $user->getFromDB($this->options['_old_user']['users_id']); $author_email = UserEmail::getDefaultForUser($user->fields['id']); $author_lang = $user->fields["language"]; $author_id = $user->fields['id']; if (!empty($this->options['_old_user']['alternative_email']) && $this->options['_old_user']['alternative_email'] != $author_email && NotificationMail::isUserAddressValid($this->options['_old_user']['alternative_email'])) { $author_email = $this->options['_old_user']['alternative_email']; } if (empty($author_lang)) { $author_lang = $CFG_GLPI["language"]; } if (empty($author_id)) { $author_id = -1; } $this->addToAddressesList(array('email' => $author_email, 'language' => $author_lang, 'users_id' => $author_id)); } }
<?php include "../../../inc/includes.php"; if (isset($_POST["send"])) { $mmail = new NotificationMail(); $query = "SELECT email FROM glpi_useremails WHERE users_id=" . $_SESSION['glpiID']; if ($result = $DB->query($query)) { if ($DB->numrows($result) > 0) { $row = $DB->fetch_assoc($result); $mmail->From = $row['email']; $mmail->FromName = $row['email']; } } $body = str_replace("\\r", "", str_replace("\\n", "\n", $_POST['body'])); if ($_POST['users_id_ticketmail']) { $address = PluginTicketmailProfile::getEmail($_POST['users_id_ticketmail']); } else { $address = $_POST["address"]; } if (!NotificationMail::isUserAddressValid($address)) { Session::addMessageAfterRedirect(__("Invalid email address"), false, ERROR); } $mmail->AddAddress($address, $address); $mmail->Subject = $_POST["subject"]; $mmail->Body = $body; $mmail->MessageID = "GLPI-ticketmail" . time() . "." . rand() . "@" . php_uname('n'); if (!$mmail->Send()) { Session::addMessageAfterRedirect(__("Your email could not be processed.\nIf the problem persists, contact the administrator"), false, ERROR); } else { Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email was sent to %s'), $address), $_POST["subject"] . "\n")); $changes[0] = 0;
function showFormMailServerConfig() { global $LANG, $CFG_GLPI; echo "<div>"; echo "<form action='" . getItemTypeFormURL(__CLASS__) . "' method='post'>"; echo "<table class='tab_cadre_fixe'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['setup'][704] . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][202] . " :</td><td>"; Dropdown::showYesNo("use_mailing", $CFG_GLPI["use_mailing"]); echo "</td>"; if ($CFG_GLPI['use_mailing']) { echo "<td >" . $LANG['setup'][227] . " :</td>"; echo "<td><input type='text' name='url_base' size='40' value='" . $CFG_GLPI["url_base"] . "'>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][203] . " :</td>"; echo "<td><input type='text' name='admin_email' size='40' value='" . $CFG_GLPI["admin_email"] . "'>"; if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_email"])) { echo "<span class='red'> " . $LANG['mailing'][110] . "</span>"; } echo "</td>"; echo "<td >" . $LANG['setup'][208] . " :</td>"; echo "<td><input type='text' name='admin_email_name' size='40' value='" . $CFG_GLPI["admin_email_name"] . "'>"; echo " </td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td >" . $LANG['setup'][207] . " :</td>"; echo "<td><input type='text' name='admin_reply' size='40' value='" . $CFG_GLPI["admin_reply"] . "'>"; if (!NotificationMail::isUserAddressValid($CFG_GLPI["admin_reply"])) { echo "<span class='red'> " . $LANG['mailing'][110] . "</span>"; } echo " </td>"; echo "<td >" . $LANG['setup'][209] . " :</td>"; echo "<td><input type='text' name='admin_reply_name' size='40' value='" . $CFG_GLPI["admin_reply_name"] . "'>"; echo " </td></tr>"; if (!function_exists('mail')) { echo "<tr class='tab_bg_2'><td class='center' colspan='2'>"; echo "<span class='red'>" . $LANG['setup'][217] . " :</span>" . $LANG['setup'][218] . "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][204] . " :</td>"; echo "<td colspan='3'><textarea cols='60' rows='3' name='mailing_signature'>" . $CFG_GLPI["mailing_signature"] . "</textarea></td></tr>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['setup'][660] . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][231] . " :</td><td>"; $mail_methods = array(MAIL_MAIL => $LANG['setup'][650], MAIL_SMTP => $LANG['setup'][651], MAIL_SMTPSSL => $LANG['setup'][652], MAIL_SMTPTLS => $LANG['setup'][653]); Dropdown::showFromArray("smtp_mode", $mail_methods, array('value' => $CFG_GLPI["smtp_mode"])); echo "</td><td colspan='2' class='center'>"; echo "<input class='submit' type='submit' name='test_smtp_send' value=\"" . $LANG['setup'][229] . "\">"; echo "</td></tr>"; echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][232] . " :</td>"; echo "<td><input type='text' name='smtp_host' size='40' value='" . $CFG_GLPI["smtp_host"] . "'>"; echo "</td>"; echo "<td >" . $LANG['setup'][234] . " :</td>"; echo "<td><input type='text' name='smtp_username' size='40' value='" . $CFG_GLPI["smtp_username"] . "'></td></tr>"; echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][175] . " :</td>"; echo "<td><input type='text' name='smtp_port' size='5' value='" . $CFG_GLPI["smtp_port"] . "'>"; echo "</td>"; echo "<td >" . $LANG['setup'][235] . " :</td>"; echo "<td><input type='password' name='smtp_passwd' size='40' value='' autocomplete='off'>"; echo "</td></tr>"; } else { echo "</tr>"; } $options['candel'] = false; $this->showFormButtons($options); /* echo "<tr class='tab_bg_2'><td class='center' colspan='4'>"; echo "<input class='submit' type='submit' name='update' value='".$LANG['buttons'][2]."'>"; echo "</td></tr>"; echo "</table></form>";*/ }
/** * Print the ticket user form for notification * * @param $ID integer ID of the item * @param $options array * * @return Nothing (display) **/ function showForm($ID, $options = array()) { global $CFG_GLPI, $LANG; $this->check($ID, 'w'); echo "<br><form method='post' action='" . $CFG_GLPI['root_doc'] . "/front/popup.php'>"; echo "<div class='center'>"; echo "<table class='tab_cadre'>"; echo "<tr class='tab_bg_2'><td>" . $LANG['job'][38] . " :</td>"; echo "<td>"; $ticket = new Ticket(); if ($ticket->getFromDB($this->fields["tickets_id"])) { echo $ticket->getField('name'); } echo "</td></tr>"; $user = new User(); $email = ""; if ($user->getFromDB($this->fields["users_id"])) { $email = $user->getField('email'); } echo "<tr class='tab_bg_2'><td>" . $LANG['common'][34] . " :</td>"; echo "<td>" . $user->getName() . "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['job'][19] . " :</td>"; echo "<td>"; Dropdown::showYesNo('use_notification', $this->fields['use_notification']); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][118] . " :</td>"; echo "<td>"; if (!empty($email) && NotificationMail::isUserAddressValid($email)) { echo $email; } else { echo "<input type='text' size='40' name='alternative_email' value='" . $this->fields['alternative_email'] . "'>"; } echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='2'>"; echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</td></tr>"; echo "</table></div></form>"; }
/** * Try to get login of external auth method * * @param $authtype extenral auth type * * @return boolean : user login success **/ function getAlternateAuthSystemsUserLogin($authtype = 0) { global $CFG_GLPI; switch ($authtype) { case self::CAS: include GLPI_PHPCAS; phpCAS::client(CAS_VERSION_2_0, $CFG_GLPI["cas_host"], intval($CFG_GLPI["cas_port"]), $CFG_GLPI["cas_uri"], false); // no SSL validation for the CAS server phpCAS::setNoCasServerValidation(); // force CAS authentication phpCAS::forceAuthentication(); $this->user->fields['name'] = phpCAS::getUser(); return true; case self::EXTERNAL: $login_string = $_SERVER[$CFG_GLPI["existing_auth_server_field"]]; $login = $login_string; $pos = stripos($login_string, "\\"); if (!$pos === false) { $login = substr($login_string, $pos + 1); } if ($CFG_GLPI['existing_auth_server_field_clean_domain']) { $pos = stripos($login, "@"); if (!$pos === false) { $login = substr($login, 0, $pos); } } if (isValidLogin($login)) { $this->user->fields['name'] = $login; return true; } break; case self::X509: // From eGroupWare http://www.egroupware.org // an X.509 subject looks like: // CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/ $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']); while ($sslattrib = next($sslattribs)) { list($key, $val) = explode('=', $sslattrib); $sslattributes[$key] = $val; } if (isset($sslattributes[$CFG_GLPI["x509_email_field"]]) && NotificationMail::isUserAddressValid($sslattributes[$CFG_GLPI["x509_email_field"]]) && isValidLogin($sslattributes[$CFG_GLPI["x509_email_field"]])) { $this->user->fields['name'] = $sslattributes[$CFG_GLPI["x509_email_field"]]; // Can do other things if need : only add it here $this->user->fields['email'] = $this->user->fields['name']; return true; } break; } return false; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("config", UPDATE); $notificationmail = new NotificationMailSetting(); if (!empty($_POST["test_smtp_send"])) { NotificationMail::testNotification(); Html::back(); } else { if (!empty($_POST["update"])) { $config = new Config(); $config->update($_POST); Html::back(); } } Html::header(Notification::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "notification", "config"); $notificationmail->display(array('id' => 1)); Html::footer();
static function testNotification() { global $CFG_GLPI, $LANG; $mmail = new NotificationMail(); $mmail->AddCustomHeader("Auto-Submitted: auto-generated"); $mmail->SetFrom($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"]); $mmail->AddAddress($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"]); $mmail->Subject = "[GLPI] " . $LANG['mailing'][32]; $mmail->Body = $LANG['mailing'][31] . "\n-- \n" . $CFG_GLPI["mailing_signature"]; if (!$mmail->Send()) { addMessageAfterRedirect($LANG['setup'][206], false, ERROR); } else { addMessageAfterRedirect($LANG['setup'][205]); } }
function sendMailRefusedResponse($to = '', $subject = '') { global $CFG_GLPI, $LANG; $mmail = new NotificationMail(); $mmail->AddCustomHeader("Auto-Submitted: auto-replied"); $mmail->SetFrom($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"]); $mmail->AddAddress($to); $mmail->Subject = $LANG['mailgate'][16] . ' ' . $subject; $mmail->Body = $LANG['mailgate'][9] . "\n-- \n" . $CFG_GLPI["mailing_signature"]; $mmail->Send(); }
// "7bit", "binary", "base64", and "quoted-printable". $enc = ''; } if (isset($_GET['help'])) { die("usage php testmail.php [ --from=email ] --to=email [ --enc=7bit|8bit|binary|base64|quoted-printable ]\n"); } $dat = date('r'); $secret = "l'été, ça roule !"; echo "From : $from\n"; echo "To : $dest\n"; echo "Date : $dat\n"; $mmail = new NotificationMail(); $mmail->From=$from; $mmail->FromName="GLPI test"; $mmail->isHTML(true); if ($enc) { $mmail->Encoding = $enc; } $mmail->Subject="GLPI test mail" . ($enc ? " ($enc)" : ''); $mmail->Body="<html><body><h3>GLPI test mail</h3><p>Encoding = <span class='b'>$enc</span></p>". "<p>Date = <span class='b'>$dat</span></p><p>Secret = <span class='b'>$secret</span>". "</p></body></html>"; $mmail->AltBody="GLPI test mail\nEncoding : $enc\nDate : $dat\nSecret=$secret"; $mmail->AddAddress($dest, "");
/** * show tooltip for user notification informations * * @param $type integer : user type * @param $canedit boolean : can edit ? * * @return nothing display **/ function showUsersAssociated($type, $canedit) { global $CFG_GLPI, $LANG; $showuserlink = 0; if (haveRight('user', 'r')) { $showuserlink = 2; } $usericon = self::getActorIcon('user', $type); $user = new User(); if (isset($this->users[$type]) && count($this->users[$type])) { foreach ($this->users[$type] as $k => $d) { $save_showuserlink = $showuserlink; echo "{$usericon} "; if ($k) { $userdata = getUserName($k, $showuserlink); } else { $email = $d['alternative_email']; $userdata = "<a href='mailto:{$email}'>{$email}</a>"; $showuserlink = false; } if ($showuserlink) { echo $userdata['name'] . " " . showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } else { echo $userdata; } if ($CFG_GLPI['use_mailing']) { $text = $LANG['job'][19] . " : " . Dropdown::getYesNo($d['use_notification']) . '<br>'; if ($d['use_notification']) { $uemail = $d['alternative_email']; if (empty($uemail) && $user->getFromDB($d['users_id'])) { $uemail = $user->getField('email'); } $text .= $LANG['mailing'][118] . " : " . $uemail; if (!NotificationMail::isUserAddressValid($uemail)) { $text .= "<span class='red'>" . $LANG['mailing'][110] . "</span>"; } } echo " "; if ($canedit || $d['users_id'] == getLoginUserID()) { $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => 'edit_user_notification&id=' . $d['id']); showToolTip($text, $opt); } } if ($canedit) { echo " <a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?delete_user=delete_user&id=" . $d['id'] . "&tickets_id=" . $this->fields['id'] . "' title=\"" . $LANG['buttons'][6] . "\">\n <img src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png'\n alt=\"" . $LANG['buttons'][6] . "\" title=\"" . $LANG['buttons'][6] . "\"></a>"; } echo "<br>"; $showuserlink = $save_showuserlink; } } }
/** * Assign and actor in a ticket for an authenticated user * * @param $params array of options (ticket, id2name) * @param $protocol the communication protocol used * * @return array of hashtable as glpi.getTicket **/ static function methodsetTicketAssign($params, $protocol) { global $DB, $CFG_GLPI; if (isset($params['help'])) { return array('ticket' => 'integer,mandatory', 'user' => 'integer,optional', 'supplier' => 'integer,optional', 'group' => 'integer,optional', 'user_email' => 'string,optional', 'use_email_notification' => 'bool,optional', 'help' => 'bool,optional'); } if (!Session::getLoginUserID()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } if (!Session::haveRight("assign_ticket", "1")) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if (!isset($params['user']) && !isset($params['group']) && !isset($params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'user or group or supplier'); } $ticket = new Ticket(); if (!isset($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket'); } if (!is_numeric($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket=' . $params['ticket']); } if (!$ticket->can($params['ticket'], 'r')) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND); } if (!$ticket->getFromDB($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket'); } $ticket_user = new Ticket_User(); $user = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); // technician : optionnal, default = none if (isset($params['user'])) { if (!is_numeric($params['user'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user'); } $user['users_id'] = $params['user']; if ($ticket->getFromDB($params['ticket'])) { $entity = $ticket->getField('entities_id'); } if (!$ticket_user->can(-1, 'w', $user) || !self::checkUserRights($params['user'], "own_ticket", 1, $entity)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isUser(CommonITILActor::ASSIGN, $user['users_id'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'User already assign for this ticket'); } if (isset($params['user_email'])) { if (!NotificationMail::isUserAddressValid($params['user_email'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user_email'); } $user['alternative_email'] = $params['user_email']; $user['use_notification'] = 1; } else { if (isset($params['use_email_notification']) && $params['use_email_notification']) { $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 1); } else { if (isset($params['use_email_notification']) && !$params['use_email_notification']) { $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 0); } } } if (!$ticket_user->add($user)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'user not assign'); } } // group (technicians group) : optionnal, default = none $group_ticket = new Group_Ticket(); $group = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); if (isset($params['group'])) { if (!is_numeric($params['group'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'group'); } $group['groups_id'] = $params['group']; if (!$group_ticket->can(-1, 'w', $group)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isGroup(CommonITILActor::ASSIGN, $params['group'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Group already assign for this ticket'); } if (!$group_ticket->add($group)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'group not assign'); } } // supplier to assign : optionnal, default = none $supplier_ticket = new Supplier_Ticket(); $supplier = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN); if (isset($params['supplier'])) { if (!is_numeric($params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'supplier'); } $supplier['suppliers_id'] = $params['supplier']; if (!$supplier_ticket->can(-1, 'w', $supplier)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if ($ticket->isSupplier(CommonITILActor::ASSIGN, $params['supplier'])) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Supplier already assign for this ticket'); } if (!$supplier_ticket->add($supplier)) { return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'supplier not assign'); } } return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol); return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError()); }
/** * @param $pid * @param $data * @param $server * @param $prof * @param $verb * @param $mail **/ function syncEntity($pid, $data, $server, $prof, $verb, $mail) { global $DB, $LANG, $CFG_GLPI; // Re-establish DB connexion - mandatory in each forked process if (!DBConnection::switchToMaster()) { echo " {$pid}: lost DB connection\n"; return 0; } // Server from entity (if not given from option) if ($data['authldaps_id'] > 0) { $server = $data['authldaps_id']; } $entity = new Entity(); if ($entity->getFromDB($id = $data['id'])) { $tps = microtime(true); if ($verb) { echo " {$pid}: Synchonizing entity '" . $entity->getField('completename') . "' ({$id}, mail={$mail})\n"; } $sql = "SELECT DISTINCT glpi_users.*\n FROM glpi_users\n INNER JOIN glpi_profiles_users\n ON (glpi_profiles_users.users_id = glpi_users.id\n AND glpi_profiles_users.entities_id = {$id}"; if ($prof > 0) { $sql .= " AND glpi_profiles_users.profiles_id = {$prof}"; } $sql .= ")\n WHERE glpi_users.authtype = " . Auth::LDAP; if ($server > 0) { $sql .= " AND glpi_users.auths_id = {$server}"; } $users = array(); $results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0); $req = $DB->request($sql); $i = 0; $nb = $req->numrows(); foreach ($req as $row) { $i++; $result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $row['name']), AuthLDAP::ACTION_SYNCHRONIZE, $row['auths_id']); if ($result) { $results[$result['action']] += 1; $users[$row['id']] = $row['name']; if ($result['action'] == AuthLDAP::USER_SYNCHRONIZED) { if ($verb) { echo " {$pid}: User '" . $row['name'] . "' synchronized ({$i}/{$nb})\n"; } } else { if ($verb) { echo " {$pid}: User '" . $row['name'] . "' deleted\n"; } } } else { if ($verb) { echo " {$pid}: Problem with LDAP for user '" . $row['name'] . "'\n"; } } } $tps = microtime(true) - $tps; printf(" %d: Entity '%s' - Synchronized: %d, Deleted from LDAP: %d, Time: %.2f\"\n", $pid, $entity->getField('completename'), $results[AuthLDAP::USER_SYNCHRONIZED], $results[AuthLDAP::USER_DELETED_LDAP], $tps); if ($mail) { $report = ''; $user = new User(); foreach ($users as $id => $name) { if ($user->getFromDB($id)) { $logs = Log::getHistoryData($user, 0, $_SESSION['glpilist_limit'], "`date_mod`='" . $_SESSION['glpi_currenttime'] . "'"); if (count($logs)) { $report .= "\n{$name} (" . $user->getName() . ")\n"; foreach ($logs as $log) { $report .= "\t"; if ($log['field']) { $report .= $log['field'] . ": "; } $report .= Html::clean($log['change']) . "\n"; } } } else { $report .= "\n" . $name . "\n\t deleted\n"; } } if ($report) { $report = "Synchronization of already imported users\n " . "Entité: " . $entity->getField('completename') . "\n " . "Date: " . Html::convDateTime($_SESSION['glpi_currenttime']) . "\n " . $report; $entdata = new Entity(); $mmail = new NotificationMail(); $mmail->AddCustomHeader("Auto-Submitted: auto-generated"); $mmail->From = $CFG_GLPI["admin_email"]; $mmail->FromName = "GLPI"; $mmail->Subject = "[GLPI] LDAP directory link"; $mmail->Body = $report . "\n--\n" . $CFG_GLPI["mailing_signature"]; if ($mail & 1 && $entdata->getFromDB($entity->getField('id')) && $entdata->fields['admin_email']) { $mmail->AddAddress($entdata->fields['admin_email']); } else { if ($mail & 1 && $verb) { echo " {$pid}: No address found for email entity\n"; } $mail = $mail & 2; } if ($mail & 2 && $CFG_GLPI['admin_email']) { $mmail->AddAddress($CFG_GLPI['admin_email']); } else { if ($mail & 2 && $verb) { echo " {$pid}: No address found for email admin\n"; } $mail = $mail & 1; } if ($mail) { if ($mmail->Send() && $verb) { echo " {$pid}: Report sent by email\n"; } } else { echo " {$pid}: Cannot send report (" . $entity->getField('completename') . ") " . "invalid address\n"; } } } return $results[AuthLDAP::USER_DELETED_LDAP] + $results[AuthLDAP::USER_SYNCHRONIZED]; } return 0; }
/** * show tooltip for user notification information * * @param $type integer user type * @param $canedit boolean can edit ? * * @return nothing display **/ function showUsersAssociated($type, $canedit) { global $CFG_GLPI; $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 2; } $usericon = self::getActorIcon('user', $type); $user = new User(); if (isset($this->users[$type]) && count($this->users[$type])) { foreach ($this->users[$type] as $d) { $k = $d['users_id']; echo "{$usericon} "; if ($k) { $userdata = getUserName($k, 2); } else { $email = $d['alternative_email']; $userdata = "<a href='mailto:{$email}'>{$email}</a>"; } if ($k) { $param = array('display' => false); if ($showuserlink) { $param['link'] = $userdata["link"]; } echo $userdata['name'] . " " . Html::showToolTip($userdata["comment"], $param); } else { echo $userdata; } if ($CFG_GLPI['use_mailing']) { $text = __('Email followup') . " " . Dropdown::getYesNo($d['use_notification']) . '<br>'; if ($d['use_notification']) { $uemail = $d['alternative_email']; if (empty($uemail) && $user->getFromDB($d['users_id'])) { $uemail = $user->getDefaultEmail(); } $text .= sprintf(__('%1$s: %2$s'), __('Email'), $uemail); if (!NotificationMail::isUserAddressValid($uemail)) { $text .= " <span class='red'>" . __('Invalid email address') . "</span>"; } } echo " "; if ($canedit || $d['users_id'] == Session::getLoginUserID()) { $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => 'edit_user_notification&itemtype=' . $this->getType() . '&id=' . $d['id']); Html::showToolTip($text, $opt); } } if ($canedit) { echo " "; Html::showSimpleForm($this->getFormURL(), 'delete_user', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png"); } echo "<br>"; } } }
/** * @see CommonDBTM::prepareInputForAdd() **/ function prepareInputForAdd($input) { if (isset($input["passwd"])) { if (empty($input["passwd"])) { unset($input["passwd"]); } else { $input["passwd"] = Toolbox::encrypt(stripslashes($input["passwd"]), GLPIKEY); } } if (isset($input['mail_server']) && !empty($input['mail_server'])) { $input["host"] = Toolbox::constructMailServerConfig($input); } if (!NotificationMail::isUserAddressValid($input['name'])) { Session::addMessageAfterRedirect(__('Invalid email address'), false, ERROR); } return $input; }
/** * Get the reply to address * * @param $options array * * @return the reply to address **/ function getReplyTo($options = array()) { global $DB, $CFG_GLPI; //If the entity administrator's address is defined, return it foreach ($DB->request('glpi_entities', array('id' => $this->getEntity())) as $data) { if (NotificationMail::isUserAddressValid($data['admin_reply'])) { return array('email' => $data['admin_reply'], 'name' => $data['admin_reply_name']); } } //Entity admin is not defined, return the global admin's address return array('email' => $CFG_GLPI['admin_reply'], 'name' => $CFG_GLPI['admin_reply_name']); }
/** * Send password recovery for a user. * * @param $email email of the user * * @return nothing : send email or display error message **/ function forgetPassword($email) { global $CFG_GLPI; echo "<div class='center'>"; if ($this->getFromDBbyEmail($email, "`glpi_users`.`is_active` AND NOT `glpi_users`.`is_deleted`")) { // Send token if auth DB or not external auth defined if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) { if (NotificationMail::isUserAddressValid($email)) { $input['password_forget_token'] = sha1(Toolbox::getRandomString(30)); $input['password_forget_token_date'] = $_SESSION["glpi_currenttime"]; $input['id'] = $this->fields['id']; $this->update($input); // Notication on root entity (glpi_users.entities_id is only a pref) NotificationEvent::raiseEvent('passwordforget', $this, array('entities_id' => 0)); _e('An email has been sent to your email address. The email contains information for reset your password.'); } else { _e('Invalid email address'); } } else { _e("The authentication method configuration doesn't allow you to change your password."); } } else { _e('Email address not found.'); } echo "<br>"; echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/index.php\">" . __s('Back') . "</a>"; echo "</div>"; }
/** * @param $to (default '') * @param $subject (default '') **/ function sendMailRefusedResponse($to = '', $subject = '') { global $CFG_GLPI; $mmail = new NotificationMail(); $mmail->AddCustomHeader("Auto-Submitted: auto-replied"); $mmail->SetFrom($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"]); $mmail->AddAddress($to); // Normalized header, no translation $mmail->Subject = 'Re: ' . $subject; $mmail->Body = __("Your email could not be processed.\nIf the problem persists, contact the administrator") . "\n-- \n" . $CFG_GLPI["mailing_signature"]; $mmail->Send(); }