The Framework Code

class/framework/utility/fmailer.php

File List

<?php
/**
 * This provides a class that supports mailing using either the built in PHP mail() function
 * or using the SMTP parts of PHPMailer
 *
 * @author Lindsay Marshall <lindsay.marshall@ncl.ac.uk>
 * @copyright 2017-2020 Newcastle University
 * @package Framework
 * @subpackage Utility
 */
    namespace Framework\Utility;

    use Config\Config;
    use PHPMailer\PHPMailer\PHPMailer;
/**
 * The FMailer class
 */
    class FMailer extends PHPMailer
    {
/**
 * The constructor
 *
 * @psalm-suppress UndefinedConstant Some of the constants are not defined in some installations.
 *
 * @param bool          $exceptions    Passed to the PHPMailer constructor
 */
        public function __construct(bool $exceptions = TRUE)
        {
            parent::__construct($exceptions);
            /** @psalm-suppress TypeDoesNotContainType */
            if (Config::USEPHPM)
            {
                $this->isSMTP();
                $this->Host = Config::SMTPHOST;
                $this->Port = Config::SMTPPORT;
                if (Config::PROTOCOL !== '')
                {
                    $this->SMTPSecure = Config::PROTOCOL;
                }
                if (\Config\Config::SMTPUSER !== '')
                {
                    $this->SMTPAuth = TRUE;
                    $this->Username = Config::SMTPUSER;
                    $this->Password = Config::SMTPPW;
                }
            }
        }
    }
?>