Overview

Namespaces

  • Glpi
    • Cache
    • Console
      • Command
      • Database
      • Ldap
      • Migration
      • Task
    • Exception
  • None

Classes

  • AbstractQuery
  • Ajax
  • Alert
  • API
  • APIClient
  • APIRest
  • APIXmlrpc
  • Auth
  • AuthLDAP
  • AuthLdapReplicate
  • AuthMail
  • AutoUpdateSystem
  • Backup
  • Blacklist
  • BlacklistedMailContent
  • Budget
  • BudgetType
  • BusinessCriticity
  • Calendar
  • Calendar_Holiday
  • CalendarSegment
  • Cartridge
  • CartridgeItem
  • CartridgeItem_PrinterModel
  • CartridgeItemType
  • Central
  • Certificate
  • Certificate_Item
  • CertificateType
  • Change
  • Change_Group
  • Change_Item
  • Change_Problem
  • Change_Supplier
  • Change_Ticket
  • Change_User
  • ChangeCost
  • ChangeTask
  • ChangeValidation
  • CliMigration
  • CommonDBChild
  • CommonDBConnexity
  • CommonDBRelation
  • CommonDBTM
  • CommonDBVisible
  • CommonDCModelDropdown
  • CommonDevice
  • CommonDeviceModel
  • CommonDeviceType
  • CommonDropdown
  • CommonGLPI
  • CommonImplicitTreeDropdown
  • CommonITILActor
  • CommonITILCost
  • CommonITILObject
  • CommonITILTask
  • CommonITILValidation
  • CommonTreeDropdown
  • Computer
  • Computer_Item
  • Computer_SoftwareLicense
  • Computer_SoftwareVersion
  • ComputerAntivirus
  • ComputerModel
  • ComputerType
  • ComputerVirtualMachine
  • Config
  • Consumable
  • ConsumableItem
  • ConsumableItemType
  • Contact
  • Contact_Supplier
  • ContactType
  • Contract
  • Contract_Item
  • Contract_Supplier
  • ContractCost
  • ContractType
  • CronTask
  • CronTaskLog
  • Datacenter
  • DBConnection
  • DBmysql
  • DBmysqlIterator
  • DbUtils
  • DCRoom
  • DeviceBattery
  • DeviceBatteryModel
  • DeviceBatteryType
  • DeviceCase
  • DeviceCaseModel
  • DeviceCaseType
  • DeviceControl
  • DeviceControlModel
  • DeviceDrive
  • DeviceDriveModel
  • DeviceFirmware
  • DeviceFirmwareModel
  • DeviceFirmwareType
  • DeviceGeneric
  • DeviceGenericModel
  • DeviceGenericType
  • DeviceGraphicCard
  • DeviceGraphicCardModel
  • DeviceHardDrive
  • DeviceHardDriveModel
  • DeviceMemory
  • DeviceMemoryModel
  • DeviceMemoryType
  • DeviceMotherboard
  • DeviceMotherBoardModel
  • DeviceNetworkCard
  • DeviceNetworkCardModel
  • DevicePci
  • DevicePciModel
  • DevicePowerSupply
  • DevicePowerSupplyModel
  • DeviceProcessor
  • DeviceProcessorModel
  • DeviceSensor
  • DeviceSensorModel
  • DeviceSensorType
  • DeviceSimcard
  • DeviceSimcardType
  • DeviceSoundCard
  • DeviceSoundCardModel
  • DisplayPreference
  • Document
  • Document_Item
  • DocumentCategory
  • DocumentType
  • Domain
  • Dropdown
  • DropdownTranslation
  • Enclosure
  • EnclosureModel
  • Entity
  • Entity_KnowbaseItem
  • Entity_Reminder
  • Entity_RSSFeed
  • Fieldblacklist
  • FieldUnicity
  • Filesystem
  • FQDN
  • FQDNLabel
  • GLPI
  • Glpi\Cache\SimpleCache
  • Glpi\Console\AbstractCommand
  • Glpi\Console\Application
  • Glpi\Console\CommandLoader
  • Glpi\Console\Database\CheckCommand
  • Glpi\Console\Database\InstallCommand
  • Glpi\Console\Database\UpdateCommand
  • Glpi\Console\Ldap\SynchronizeUsersCommand
  • Glpi\Console\Migration\BuildMissingTimestampsCommand
  • Glpi\Console\Migration\MyIsamToInnoDbCommand
  • Glpi\Console\Task\UnlockCommand
  • Glpi\Event
  • GLPIMailer
  • GLPINetwork
  • GLPIPDF
  • GLPIUploadHandler
  • Group
  • Group_KnowbaseItem
  • Group_Problem
  • Group_Reminder
  • Group_RSSFeed
  • Group_Ticket
  • Group_User
  • Holiday
  • Html
  • HTMLTableBase
  • HTMLTableCell
  • HTMLTableEntity
  • HTMLTableGroup
  • HTMLTableHeader
  • HTMLTableMain
  • HTMLTableRow
  • HTMLTableSubHeader
  • HTMLTableSuperHeader
  • Infocom
  • InterfaceType
  • IPAddress
  • IPAddress_IPNetwork
  • IPNetmask
  • IPNetwork
  • IPNetwork_Vlan
  • Item_DeviceBattery
  • Item_DeviceCase
  • Item_DeviceControl
  • Item_DeviceDrive
  • Item_DeviceFirmware
  • Item_DeviceGeneric
  • Item_DeviceGraphicCard
  • Item_DeviceHardDrive
  • Item_DeviceMemory
  • Item_DeviceMotherboard
  • Item_DeviceNetworkCard
  • Item_DevicePci
  • Item_DevicePowerSupply
  • Item_DeviceProcessor
  • Item_Devices
  • Item_DeviceSensor
  • Item_DeviceSimcard
  • Item_DeviceSoundCard
  • Item_Disk
  • Item_Enclosure
  • Item_OperatingSystem
  • Item_Problem
  • Item_Project
  • Item_Rack
  • Item_Ticket
  • Itil_Project
  • ITILCategory
  • ITILFollowup
  • ITILSolution
  • Knowbase
  • KnowbaseItem
  • KnowbaseItem_Comment
  • KnowbaseItem_Item
  • KnowbaseItem_Profile
  • KnowbaseItem_Revision
  • KnowbaseItem_User
  • KnowbaseItemCategory
  • KnowbaseItemTranslation
  • LevelAgreement
  • LevelAgreementLevel
  • Line
  • LineOperator
  • LineType
  • Link
  • Link_Itemtype
  • Location
  • Lock
  • Log
  • MailCollector
  • Manufacturer
  • MassiveAction
  • Migration
  • MigrationCleaner
  • Monitor
  • MonitorModel
  • MonitorType
  • Netpoint
  • Network
  • NetworkAlias
  • NetworkEquipment
  • NetworkEquipmentModel
  • NetworkEquipmentType
  • NetworkInterface
  • NetworkName
  • NetworkPort
  • NetworkPort_NetworkPort
  • NetworkPort_Vlan
  • NetworkPortAggregate
  • NetworkPortAlias
  • NetworkPortDialup
  • NetworkPortEthernet
  • NetworkPortFiberchannel
  • NetworkPortInstantiation
  • NetworkPortLocal
  • NetworkPortMigration
  • NetworkPortWifi
  • Notepad
  • Notification
  • Notification_NotificationTemplate
  • NotificationAjax
  • NotificationAjaxSetting
  • NotificationEvent
  • NotificationEventAbstract
  • NotificationEventAjax
  • NotificationEventMailing
  • NotificationMailing
  • NotificationMailingSetting
  • NotificationSetting
  • NotificationSettingConfig
  • NotificationTarget
  • NotificationTargetCartridgeItem
  • NotificationTargetCertificate
  • NotificationTargetChange
  • NotificationTargetCommonITILObject
  • NotificationTargetConsumableItem
  • NotificationTargetContract
  • NotificationTargetCrontask
  • NotificationTargetDBConnection
  • NotificationTargetFieldUnicity
  • NotificationTargetInfocom
  • NotificationTargetMailCollector
  • NotificationTargetObjectLock
  • NotificationTargetPlanningRecall
  • NotificationTargetProblem
  • NotificationTargetProject
  • NotificationTargetProjectTask
  • NotificationTargetReservation
  • NotificationTargetSavedsearch_Alert
  • NotificationTargetSoftwareLicense
  • NotificationTargetTicket
  • NotificationTargetUser
  • NotificationTemplate
  • NotificationTemplateTranslation
  • NotImportedEmail
  • ObjectLock
  • OLA
  • OlaLevel
  • OlaLevel_Ticket
  • OlaLevelAction
  • OlaLevelCriteria
  • OperatingSystem
  • OperatingSystemArchitecture
  • OperatingSystemEdition
  • OperatingSystemKernel
  • OperatingSystemKernelVersion
  • OperatingSystemServicePack
  • OperatingSystemVersion
  • PDU
  • Pdu_Plug
  • PDU_Rack
  • PDUModel
  • PDUType
  • Peripheral
  • PeripheralModel
  • PeripheralType
  • Phone
  • PhoneModel
  • PhonePowerSupply
  • PhoneType
  • Planning
  • PlanningRecall
  • Plug
  • Plugin
  • Preference
  • Printer
  • PrinterModel
  • PrinterType
  • Problem
  • Problem_Supplier
  • Problem_Ticket
  • Problem_User
  • ProblemCost
  • ProblemTask
  • Profile
  • Profile_Reminder
  • Profile_RSSFeed
  • Profile_User
  • ProfileRight
  • Project
  • ProjectCost
  • ProjectState
  • ProjectTask
  • ProjectTask_Ticket
  • ProjectTaskTeam
  • ProjectTaskTemplate
  • ProjectTaskType
  • ProjectTeam
  • ProjectType
  • PurgeLogs
  • QueryExpression
  • QueryParam
  • QuerySubQuery
  • QueryUnion
  • QueuedNotification
  • Rack
  • RackModel
  • RackType
  • RegisteredID
  • Reminder
  • Reminder_User
  • Report
  • RequestType
  • Reservation
  • ReservationItem
  • RSSFeed
  • RSSFeed_User
  • Rule
  • RuleAction
  • RuleAsset
  • RuleAssetCollection
  • RuleCollection
  • RuleCriteria
  • RuleDictionnaryComputerModel
  • RuleDictionnaryComputerModelCollection
  • RuleDictionnaryComputerType
  • RuleDictionnaryComputerTypeCollection
  • RuleDictionnaryDropdown
  • RuleDictionnaryDropdownCollection
  • RuleDictionnaryManufacturer
  • RuleDictionnaryManufacturerCollection
  • RuleDictionnaryMonitorModel
  • RuleDictionnaryMonitorModelCollection
  • RuleDictionnaryMonitorType
  • RuleDictionnaryMonitorTypeCollection
  • RuleDictionnaryNetworkEquipmentModel
  • RuleDictionnaryNetworkEquipmentModelCollection
  • RuleDictionnaryNetworkEquipmentType
  • RuleDictionnaryNetworkEquipmentTypeCollection
  • RuleDictionnaryOperatingSystem
  • RuleDictionnaryOperatingSystemArchitecture
  • RuleDictionnaryOperatingSystemArchitectureCollection
  • RuleDictionnaryOperatingSystemCollection
  • RuleDictionnaryOperatingSystemServicePack
  • RuleDictionnaryOperatingSystemServicePackCollection
  • RuleDictionnaryOperatingSystemVersion
  • RuleDictionnaryOperatingSystemVersionCollection
  • RuleDictionnaryPeripheralModel
  • RuleDictionnaryPeripheralModelCollection
  • RuleDictionnaryPeripheralType
  • RuleDictionnaryPeripheralTypeCollection
  • RuleDictionnaryPhoneModel
  • RuleDictionnaryPhoneModelCollection
  • RuleDictionnaryPhoneType
  • RuleDictionnaryPhoneTypeCollection
  • RuleDictionnaryPrinter
  • RuleDictionnaryPrinterCollection
  • RuleDictionnaryPrinterModel
  • RuleDictionnaryPrinterModelCollection
  • RuleDictionnaryPrinterType
  • RuleDictionnaryPrinterTypeCollection
  • RuleDictionnarySoftware
  • RuleDictionnarySoftwareCollection
  • RuleImportComputer
  • RuleImportComputerCollection
  • RuleImportEntity
  • RuleImportEntityCollection
  • RuleMailCollector
  • RuleMailCollectorCollection
  • RuleRight
  • RuleRightCollection
  • RuleRightParameter
  • RuleSoftwareCategory
  • RuleSoftwareCategoryCollection
  • RuleTicket
  • RuleTicketCollection
  • SavedSearch
  • SavedSearch_Alert
  • SavedSearch_User
  • Search
  • Session
  • SingletonRuleList
  • SLA
  • SlaLevel
  • SlaLevel_Ticket
  • SlaLevelAction
  • SlaLevelCriteria
  • SLM
  • Software
  • SoftwareCategory
  • SoftwareLicense
  • SoftwareLicenseType
  • SoftwareVersion
  • SolutionTemplate
  • SolutionType
  • SsoVariable
  • Stat
  • State
  • Supplier
  • Supplier_Ticket
  • SupplierType
  • TaskCategory
  • TaskTemplate
  • Telemetry
  • Ticket
  • Ticket_Ticket
  • Ticket_User
  • TicketCost
  • TicketFollowup
  • TicketRecurrent
  • TicketSatisfaction
  • TicketTask
  • TicketTemplate
  • TicketTemplateHiddenField
  • TicketTemplateMandatoryField
  • TicketTemplatePredefinedField
  • TicketValidation
  • Timer
  • Toolbox
  • Transfer
  • Update
  • User
  • UserCategory
  • UserEmail
  • UserTitle
  • VirtualMachineState
  • VirtualMachineSystem
  • VirtualMachineType
  • Vlan
  • WifiNetwork
  • XHProf
  • XML

Interfaces

  • Glpi\Console\Command\ForceNoPluginsOptionCommandInterface
  • NotificationEventInterface
  • NotificationInterface

Traits

  • DCBreadcrumb

Exceptions

  • CommonDBConnexityItemNotFound
  • Glpi\Exception\ForgetPasswordException
  • Glpi\Exception\PasswordTooWeakException
  • HTMLTableCellFatherCoherentHeader
  • HTMLTableCellFatherSameRow
  • HTMLTableCellWithoutFather
  • HTMLTableUnknownHeader
  • HTMLTableUnknownHeaders
  • HTMLTableUnknownHeadersOrder

Functions

  • __
  • __s
  • _n
  • _nx
  • _sn
  • _sx
  • _x
  • autoName
  • closeDBConnections
  • contructListFromTree
  • contructTreeFromList
  • countDistinctElementsInTable
  • countElementsInTable
  • countElementsInTableForEntity
  • countElementsInTableForMyEntities
  • exportArrayToDB
  • formatUserName
  • get_hour_from_sql
  • getAllDatasFromTable
  • getAncestorsOf
  • getDateCriteria
  • getDateRequest
  • getDbRelations
  • getEntitiesRestrictCriteria
  • getEntitiesRestrictRequest
  • getForeignKeyFieldForItemType
  • getForeignKeyFieldForTable
  • getItemForItemtype
  • getItemtypeForForeignKeyField
  • getItemTypeForTable
  • getNextItem
  • getPlural
  • getPreviousItem
  • getRealQueryForTreeItem
  • getSingular
  • getSonsAndAncestorsOf
  • getSonsOf
  • getTableForItemType
  • getTableNameForForeignKeyField
  • getTreeForItem
  • getTreeLeafValueName
  • getTreeValueCompleteName
  • getTreeValueName
  • getUserName
  • glpi_autoload
  • importArrayFromDB
  • isAPI
  • isCommandLine
  • isForeignKeyField
  • isIndex
  • isPluginItemType
  • regenerateTreeCompleteName
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 
<?php
/**
 * ---------------------------------------------------------------------
 * GLPI - Gestionnaire Libre de Parc Informatique
 * Copyright (C) 2015-2018 Teclib' and contributors.
 *
 * http://glpi-project.org
 *
 * based on GLPI - Gestionnaire Libre de Parc Informatique
 * Copyright (C) 2003-2014 by the INDEPNET Development Team.
 *
 * ---------------------------------------------------------------------
 *
 * LICENSE
 *
 * This file is part of GLPI.
 *
 * GLPI is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * 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/>.
 * ---------------------------------------------------------------------
 */

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;

if (!defined('GLPI_ROOT')) {
   die("Sorry. You can't access this file directly");
}


/** GLPIPhpMailer class
 *
 * @since 0.85
**/
class GLPIMailer extends PHPMailer {

   /**
    * Constructor
    *
   **/
   function __construct() {
      global $CFG_GLPI;

      $this->WordWrap           = 80;

      $this->CharSet            = "utf-8";

      // Comes from config
      $this->SetLanguage("en", Config::getLibraryDir("PHPMailer") . "/language/");

      if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
         $this->Mailer = "smtp";
         $this->Host   = $CFG_GLPI['smtp_host'].':'.$CFG_GLPI['smtp_port'];

         if ($CFG_GLPI['smtp_username'] != '') {
            $this->SMTPAuth = true;
            $this->Username = $CFG_GLPI['smtp_username'];
            $this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
         }

         if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
            $this->SMTPSecure = "ssl";
         }

         if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
            $this->SMTPSecure = "tls";
         }

         if (!$CFG_GLPI['smtp_check_certificate']) {
            $this->SMTPOptions = ['ssl' => ['verify_peer'       => false,
                                            'verify_peer_name'  => false,
                                            'allow_self_signed' => true]];
         }
         if ($CFG_GLPI['smtp_sender'] != '') {
            $this->Sender = $CFG_GLPI['smtp_sender'];
         }
      }

      if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         $this->SMTPDebug = SMTP::DEBUG_CONNECTION;
         $this->Debugoutput = function ($message, $level) {
            Toolbox::logInFile(
               'mail-debug',
               "$level - $message"
            );
         };
      }
   }

   public static function validateAddress($address, $patternselect = "pcre8") {
      $isValid = parent::validateAddress($address, $patternselect);
      if (!$isValid && Toolbox::endsWith($address, '@localhost')) {
         //since phpmailer6, @localhost address are no longer valid...
         $isValid = parent::ValidateAddress($address . '.me');
      }
      return $isValid;
   }

   public function setLanguage($langcode = 'en', $lang_path = '') {
      if ($lang_path == '') {
         $local_path = dirname(Config::getLibraryDir('PHPMailer\PHPMailer\PHPMailer'))  . '/language/';
         if (is_dir($local_path)) {
            $lang_path = $local_path;
         }
      }
      parent::setLanguage($langcode, $lang_path);
   }
}
GLPI version 9.4.5 API API documentation generated by ApiGen