/** * メールを送信する */ public function sendmail() { $vars = ['abc' => 'ABC']; $mail = new \ebi\Mail(); $mail->to("*****@*****.**"); $mail->send_template('send.xml', $vars); /** * メール送信拡張 * @param string $address */ self::call_class_plugin_funcs('plguin_sendmail', $address); }
/** * メールの拡張 * @param string $address */ public function plguin_sendmail($address) { $mail = new \ebi\Mail(); $mail->to($address); $mail->send_template('plugin/send.xml', $vars); }
/** * @param \ebi\Log $log */ public function log_output(\ebi\Log $log) { $mail = new \ebi\Mail(); /** * @param mixed{} $arg1 メールにバインドする変数 */ $vars = \ebi\Conf::gets('vars'); /** * @param string $arg1 fromのメールアドレス */ $from = \ebi\Conf::get('from'); /** * @param string $arg1 toのメールアドレス */ $to = \ebi\Conf::get('to'); if (!empty($from)) { if (is_string($from)) { $mail->from($from); } else { if (isset($from['address'])) { $mail->from($from['address'], isset($from['name']) ? $from['name'] : null); } } } if (!empty($to)) { if (is_string($to)) { $mail->to($to); } else { if (isset($to['address'])) { $mail->to($to['address'], isset($to['name']) ? $to['name'] : null); } else { if (is_array($to)) { foreach ($to as $t) { if (isset($t['address'])) { $mail->to($t['address'], isset($t['name']) ? $t['name'] : null); } } } } } } if (!is_array($vars)) { $vars = []; } $template = ''; switch ($log->level()) { case 0: $template = 'logs/emergency.xml'; break; case 1: $template = 'logs/alert.xml'; break; case 2: $template = 'logs/critical.xml'; break; case 3: $template = 'logs/error.xml'; break; case 4: $template = 'logs/warning.xml'; break; case 5: $template = 'logs/notice.xml'; break; case 6: $template = 'logs/info.xml'; break; case 7: $template = 'logs/debug.xml'; break; } try { $mail->send_template($template, array_merge($vars, ['log' => $log, 'env' => new \ebi\Env()])); } catch (\ebi\exception\InvalidArgumentException $e) { } }
<?php $vars = ['abc' => 'ABC']; $mail = new \ebi\Mail(); $mail->to("*****@*****.**"); $mail->send_template('send.xml', $vars); $xml = \ebi\Dt::find_mail('*****@*****.**'); eq(<<<__DATA 123ABC456 ======================= Signature tokushima ======================= __DATA , $xml->message()); eq('テストサブジェクト', $xml->subject()); $vars = ['abc' => 'ABC']; $mail = new \ebi\Mail(); $mail->to("*****@*****.**"); $mail->send_template('send_html.xml', $vars); $xml = \ebi\Dt::find_mail('*****@*****.**'); eq('123ABC456' . "\n", $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'));