protected function send($level, \org\rhaco\Log $log) { if (empty($this->template_base)) { $this->template_base = \org\rhaco\Conf::get('template_base', \org\rhaco\io\File::resource_path('log_mail')); } $template = \org\rhaco\net\Path::absolute($this->template_base, $level . '_log.xml'); if (is_file($template)) { $mail = new \org\rhaco\net\mail\Mail(); $mail->send_template($template, array('log' => $log, 'env' => new \org\rhaco\lang\Env())); } }
<?php $vars = array('abc' => 'ABC'); $mail = new \org\rhaco\net\mail\Mail(); $mail->to("*****@*****.**"); $mail->send_template('send.xml', $vars); $xml = \org\rhaco\Dt::find_mail('*****@*****.**'); eq('ボディーテストABC' . PHP_EOL, $xml->message()); eq('テストサブジェクト', $xml->subject()); $vars = array('abc' => 'ABC'); $mail = new \org\rhaco\net\mail\Mail(); $mail->to("*****@*****.**"); $mail->send_template('send_html.xml', $vars); $xml = \org\rhaco\Dt::find_mail('*****@*****.**'); eq('ボディーテストABC' . PHP_EOL, $xml->message()); eq('テストサブジェクト', $xml->subject()); meq('Content-Type: text/html;', $xml->manuscript()); meq('<p class="abc">ピーボディー</p>', mb_convert_encoding($xml->manuscript(), 'UTF8', 'JIS')); meq('send_html.css', mb_convert_encoding($xml->manuscript(), 'UTF8', 'JIS'));