Ignore:
Timestamp:
Dec 7, 2021, 11:08:42 PM (3 years ago)
Author:
chronos
Message:
  • Added: Allow to switch Mail class into test mode.
  • Modified: Type checking related changes.
  • Modified: Replace global $Config references with $this->System->Config is possible.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Mail.php

    r887 r916  
    2020  private array $Priorities;
    2121  private string $Boundary;
     22  public bool $TestMode;
    2223
    2324  function __construct()
     
    2627    $this->Boundary = md5(date('r', time()));
    2728    $this->AgentIdent = 'PHP/Mail';
     29    $this->TestMode = false;
    2830    $this->Clear();
    2931  }
     
    145147    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    146148
    147     $res = mail($To, $this->Subject, $Body, $Headers);
     149    if ($this->TestMode)
     150    {
     151      echo('to: '.$To.', subject: '.$this->Subject.', body: '.$Body.', headers: '.$Headers);
     152      $res = true;
     153    } else
     154    {
     155      $res = mail($To, $this->Subject, $Body, $Headers);
     156    }
    148157    return $res;
    149158  }
Note: See TracChangeset for help on using the changeset viewer.