public static function to($email, $subject, $content, $part, $attach) { $mailconfig = Config::get('mail'); $transport = \Swift_SmtpTransport::newInstance($mailconfig['host'], $mailconfig['port'])->setUsername($mailconfig['username'])->setPassword($mailconfig['password']); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); // Create the message $message = \Swift_Message::newInstance($subject)->setFrom(array($mailconfig['from']['address'] => $mailconfig['from']['name'])); // Set the To addresses with an associative array if (!is_array($email)) { throw new \Exception("发送邮件必须是关联数组", 1); } $message->setTo($email); // Give it a body $message->setBody($content); // And optionally an alternative body if ($part) { $message->addPart($part, 'text/html'); } // Optionally add any attachments if ($attach) { $message->attach(Swift_Attachment::fromPath($attach)); } // Send the message if (!$mailer->send($message, $failures)) { return $failures; } else { return true; } }
public static function init() { self::$redis = new Client(Config::get('redis')); }
/** * CFPHP - A utility and can faster php framework * * @author xiaobeicn <*****@*****.**> */ use CFPHP\Console\Config; // CFPHP_START define('CFPHP_START', microtime(true)); // BASE_PATH define('BASE_PATH', dirname(__DIR__)); // FRAME_PATH define('FRAME_PATH', __DIR__); // 加载 vendor require FRAME_PATH . '/../vendor/autoload.php'; //配置错误提示 if (Config::get('app.debug')) { ini_set("display_errors", 1); error_reporting(E_ALL); // whoops 错误提示 $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->register(); } else { ini_set("display_errors", 0); error_reporting(0); } //时区 date_default_timezone_set(Config::get('app.timezone')); // 创建 Application $app = new CFPHP\Console\Application(); return $app;