public function checkServerAdmin($serverArgs) { $val = ArrayTools::get($serverArgs, 'SERVER_ADMIN'); if ($val !== null) { $this->checkConfig(StringTools::camelCase(StringTools::toUrlPart($val), '-')); } }
/** @param Event $event */ public function onMail($event) { /** @var $mail Mail */ $mail = $event->data; if (!$mail->from) { $mail->from = $this->moduleConfig->from; } if (!$mail->returnPath) { $mail->returnPath = $this->moduleConfig->returnPath; } $mode = $this->moduleConfig->mode; // Send mails if ($mode === self::MODE_SEND) { if ($to = $this->moduleConfig->to) { $mail->subject = '[DEBUG for ' . print_r($mail->recipients, true) . '] ' . $mail->subject; $mail->recipients = $to; $mail->recipientsCc = $mail->recipientsBcc = null; } $mail->send(); // Debug to directory } elseif ($mode === self::MODE_DIRECTORY) { if (!$this->_directory) { $this->_directory = $this->app->parseUri($this->moduleConfig->directory); } $this->_count++; $t = time(); $text = 'DATE: ' . date('Y-m-h H:i:s', $t) . chr(10) . 'TO: ' . json_encode($mail->recipients) . chr(10) . ($mail->recipientsCc ? 'CC: ' . json_encode($mail->recipientsCc) . chr(10) : '') . ($mail->recipientsBcc ? 'BCC: ' . json_encode($mail->recipientsBcc) . chr(10) : '') . 'SUBJECT: ' . $mail->subject . chr(10) . 'FROM: ' . $mail->from . chr(10) . ($mail->returnPath ? 'RETURN-PATH: ' . $mail->returnPath . chr(10) : '') . chr(10) . $mail->text; $file = trim($this->_directory . date('Y-m-d-H-i-s', $t) . ' - ' . str_pad($this->_count, 4, '0', STR_PAD_LEFT) . ' - ' . StringTools::toUrlPart($mail->subject)); file_put_contents($file . '.txt', $text); if ($mail->htmlText) { file_put_contents($file . '.htm', $mail->htmlText); } } }