public function send(?string $message = null, ?string $subject = null)
  {
    if ($message != null) {
      $this->body = $message;
    }

    if ($subject != null) {
      $this->subject = $subject;
    }

    if ($this->viewLocation != null || $this->viewLocation !== '') {
      $this->render($this->viewLocation, $this->viewArgs);
    }

    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = $this->connection['encryption'];
    $mail->SMTPKeepAlive = true;
    $mail->Host = $this->connection['host'];
    $mail->Port = $this->connection['port'];
    $mail->IsHTML(true);
    $mail->Username = $this->connection['username'];
    $mail->Password = $this->connection['password'];

    $mail->SetFrom($this->connection['from']['address'], $this->connection['from']['name']);

    $mail->Subject = $this->subject;
    $mail->Body = $this->outputdata == null ? $this->body : $this->outputdata;

    if ($this->replyTo != null) {
      $mail->addReplyTo($this->replyTo['email'], $this->replyTo['name']);
    }

    if ($this->to != null) {
      foreach($this->to as $email) {
        $mail->AddAddress($email['email'], $email['name']);
      }
    }

    if ($this->bcc != null) {
      foreach($this->bcc as $email) {
        $mail->addBCC($email['email'], $email['name']);
      }
    }

    if ($this->cc != null) {
      foreach($this->cc as $email) {
        $mail->addCC($email['email'], $email['name']);
      }
    }

    if ($this->attachment != null) {
      foreach($this->attachment as $attachment) {
        $mail->addAttachment($attachment['file'], $attachment['name']);
      }
    }

    if(!$mail->Send()) {
      return ["status" => "failed", "reason" => $mail->ErrorInfo];
    }

    return ["status" => "success"];
  }
public function send(?string $message = null, ?string $subject = null)
  {
    if ($message != null) {
      $this->body = $message;
    }

    if ($subject != null) {
      $this->subject = $subject;
    }

    if ($this->viewLocation != null || $this->viewLocation !== '') {
      $this->render($this->viewLocation, $this->viewArgs);
    }

    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = $this->connection['encryption'];
    $mail->SMTPKeepAlive = true;
    $mail->Host = $this->connection['host'];
    $mail->Port = $this->connection['port'];
    $mail->IsHTML(true);
    $mail->Username = $this->connection['username'];
    $mail->Password = $this->connection['password'];

    $mail->SetFrom($this->connection['from']['address'], $this->connection['from']['name']);

    $mail->Subject = $this->subject;
    $mail->Body = $this->outputdata == null ? $this->body : $this->outputdata;

    if ($this->replyTo != null) {
      $mail->addReplyTo($this->replyTo['email'], $this->replyTo['name']);
    }

    if ($this->to != null) {
      foreach($this->to as $email) {
        $mail->AddAddress($email['email'], $email['name']);
      }
    }

    if ($this->bcc != null) {
      foreach($this->bcc as $email) {
        $mail->addBCC($email['email'], $email['name']);
      }
    }

    if ($this->cc != null) {
      foreach($this->cc as $email) {
        $mail->addCC($email['email'], $email['name']);
      }
    }

    if ($this->attachment != null) {
      foreach($this->attachment as $attachment) {
        $mail->addAttachment($attachment['file'], $attachment['name']);
      }
    }

    if(!$mail->Send()) {
      return ["status" => "failed", "reason" => $mail->ErrorInfo];
    }

    return ["status" => "success"];
  }
public function send ( ? string $ message = null , ? string $ subject = null ) { if ( $ message != null ) { $ this -> body = $ message ; } if ( $ subject != null ) { $ this -> subject = $ subject ; } if ( $ this -> viewLocation != null || $ this -> viewLocation !== '' ) { $ this -> render ( $ this -> viewLocation , $ this -> viewArgs ) ; } $ mail = new PHPMailer ( ) ; $ mail -> IsSMTP ( ) ; $ mail -> SMTPDebug = 0 ; $ mail -> SMTPAuth = true ; $ mail -> SMTPSecure = $ this -> connection [ 'encryption' ] ; $ mail -> SMTPKeepAlive = true ; $ mail -> Host = $ this -> connection [ 'host' ] ; $ mail -> Port = $ this -> connection [ 'port' ] ; $ mail -> IsHTML ( true ) ; $ mail -> Username = $ this -> connection [ 'username' ] ; $ mail -> Password = $ this -> connection [ 'password' ] ; $ mail -> SetFrom ( $ this -> connection [ 'from' ] [ 'address' ] , $ this -> connection [ 'from' ] [ 'name' ] ) ; $ mail -> Subject = $ this -> subject ; $ mail -> Body = $ this -> outputdata == null ? $ this -> body : $ this -> outputdata ; if ( $ this -> replyTo != null ) { $ mail -> addReplyTo ( $ this -> replyTo [ 'email' ] , $ this -> replyTo [ 'name' ] ) ; } if ( $ this -> to != null ) { foreach ( $ this -> to as $ email ) { $ mail -> AddAddress ( $ email [ 'email' ] , $ email [ 'name' ] ) ; } } if ( $ this -> bcc != null ) { foreach ( $ this -> bcc as $ email ) { $ mail -> addBCC ( $ email [ 'email' ] , $ email [ 'name' ] ) ; } } if ( $ this -> cc != null ) { foreach ( $ this -> cc as $ email ) { $ mail -> addCC ( $ email [ 'email' ] , $ email [ 'name' ] ) ; } } if ( $ this -> attachment != null ) { foreach ( $ this -> attachment as $ attachment ) { $ mail -> addAttachment ( $ attachment [ 'file' ] , $ attachment [ 'name' ] ) ; } } if ( ! $ mail -> Send ( ) ) { return [ "status" => "failed" , "reason" => $ mail -> ErrorInfo ] ; } return [ "status" => "success" ] ; }
Finally send the email!!!

@param mixed ?string
@param mixed ?string
@return void
Finally send the email!!!