<?php
 require_once(dirname(__FILE__).'/../phpmailer/src/PHPMailer.php'); require_once(dirname(__FILE__).'/../phpmailer/src/SMTP.php'); require_once(dirname(__FILE__).'/../phpmailer/src/Exception.php'); class Mailer extends PHPMailer\PHPMailer\PHPMailer { public $to = array(); function init() { $this->CharSet = 'utf-8'; $this->IsHTML(true); $this->loadConf('mailer'); if($this->Mizu->Conf['ENV']=='local') { } } function loadConf($v) { $this->Conf = $this->Mizu->Conf[$v]['attr']; if($this->Conf['smtp']) { $this->IsSMTP(); } if(is_array($this->Conf)) { foreach($this->Conf as $k => $v) { if($v=="true") { $v=true; } if($k=='smtp') continue; $this->{$k} = $v; } } } function get($k) { return $this->{$k}; } function Send() { $this->Mizu->_Conf->execHook('Mailer.Send.init',$this); if($this->Mizu->Conf['db'] AND $this->Mizu->get('cnt/mailSender',0)) { $this->From = $this->Mizu->get('cnt/mailSender',0); } if($this->Mizu->Conf['ENV']=='local' AND !$this->dontChangeRecipientOnLocal) { $tmp = $this->getAllRecipientAddresses(); $this->clearAddresses(); $this->clearCCs(); $this->clearBCCs(); $to = strtr(key($tmp),array('@'=>'-at-')); $this->AddAddress('puergstaller+'.$to.'@gmail.com'); $R = parent::Send(); if(!$this->Conf['smtp']) { $R = true; } } else { $R = parent::Send(); } if($this->SMTPDebug) { exit; } return $R; } public function copyToFolder($folderPath = null) { $message = $this->MIMEHeader . $this->MIMEBody; $path = "INBOX" . (isset($folderPath) && !is_null($folderPath) ? ".".$folderPath : ""); $imapStream = imap_open("{" . $this->Host . "}" . $path , $this->Username, $this->Password); imap_append($imapStream, "{" . $this->Host . "}" . $path, $message); imap_close($imapStream); } }