function smarty_function_place($params, &$view) { if (empty($params['name'])) { return ''; } return \Pina\Place::get($params['name']); }
private static function mail() { if (empty(static::$config)) { return; } if (empty(static::$to)) { return; } $mail = new PHPMailer(); if (static::$config['mode'] == 'smtp') { $mail->isSMTP(); $mail->Host = static::$config['smtp']['host']; if (static::$config['smtp']['user']) { $mail->SMTPAuth = true; $mail->Username = static::$config['smtp']['user']; $mail->Password = static::$config['smtp']['pass']; } $mail->SMTPSecure = static::$config['smtp']['secure']; $mail->Port = static::$config['smtp']['port']; } else { $mail->isMail(); } $mail->setFrom(static::$config['from']['address'], !empty(static::$config['from']['name']) ? static::$config['from']['name'] : ''); foreach (static::$to as $u) { $mail->addAddress($u['address'], $u['name']); } if (!empty(static::$config['reply']['address'])) { $mail->addReplyTo(static::$config['reply']['address'], !empty(static::$config['reply']['name']) ? static::$config['reply']['name'] : ''); } foreach (static::$cc as $u) { $mail->addCC($u['address'], $u['name']); } foreach (static::$bcc as $u) { $mail->addBCC($u['address'], $u['name']); } $mail->CharSet = App::charset(); $mail->Subject = Place::get('mail_subject'); $mail->Body = static::$content; $mail->AltBody = Place::get('mail_alternative'); if ($mail->AltBody) { $mail->isHTML(true); } if (!$mail->send()) { Log::error("mail", "error send email to " . json_encode($mail, JSON_UNESCAPED_UNICODE)); return false; } return true; }