添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
[搭建邮件服务器,过程非常简单](https://blog.csdn.net/gyxuehu/article/details/78500645) 使用队列方式异步发送邮件防页面卡死,学完就知道强大之处 一、邮件发送原理 ![](https://img.kancloud.cn/e4/87/e4873044d411b5731e0bd7e03f1fc62d_918x500.png) 二、利用[phpmailer](https://github.com/PHPMailer/PHPMailer)类实现邮件发送 // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php'; // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true); try { //Server settings $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp1.example.com'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'secret'; // SMTP password $mail->charset ='UTF-8'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('[email protected]', 'Mailer'); $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient $mail->addAddress('[email protected]'); // Name is optional $mail->addReplyTo('[email protected]', 'Information'); $mail->addCC('[email protected]'); $mail->addBCC('[email protected]'); // Attachments $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = '主题'; $mail->Body = 'This is the HTML message body in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->msgHTML(file_get_contents('./test.html')); $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; 三、为什么需要队列 我们需要给网站所有用户发送一封系统通知邮件,假设网站有10000个注册用户,发送每封邮件需要0.1秒,执行一次发送通知操作需要多长时间?10000 x 0.1 = 1000 四、在phpcli模式下测试队列 create table users ( user_id int(5) not null auto_increment, user_email varchar(40) not null, user_password char(32) not null, primary key(user_id) )engine=myisam default charset=utf8; create table task_list ( task_id int(5) not null auto_increment, user_email varchar(40) not null, status int(2) not null, create_time datetime not null, update_time datetime not null, primary key(task_id) )engine=myisam default charset utf8; insert into task_list(user_email,status,create_time,update_time) VALUES( '[email protected]', 0, now(), now() ); insert into task_list(user_email,status,create_time,update_time) VALUES( '[email protected]', 0, now(), now() ); 五、Ajax异步触发队列 1. 建立用户表存储注册的用户 2. 实现注册功能,当注册成功之后,把用户email插入邮件队列表中 3. 使用ajax触发队列 ![](https://img.kancloud.cn/81/b8/81b8eb35f8c369496fed5d1106f7cde2_944x472.png) ![](https://img.kancloud.cn/d5/c7/d5c7f71e33897bdf04f4415eb73316f2_583x103.png) ![](https://img.kancloud.cn/a7/09/a7094cff806668b4267d156fbafe99cf_692x461.png) do_queue.php exec("/php7/php.exe queue.php"); queue.php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php'; function sendEmail($host, $fromEmail, $fromPwd, $fromName, $toEmail, $toName, $subject, $content){ $mail = new PHPMailer(true); try { //Server settings $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output $mail->isSMTP(); // 设置邮件使用 SMTP $mail->Host = 'smtp1.example.com'; // 邮箱服务器地址 $mail->SMTPAuth = true; // 启用 SMTP 身份验证 $mail->charset = 'UTF-8'; $mail->Username = '[email protected]'; // SMTP 邮箱地址 $mail->Password = 'secret'; // 邮箱密码 $mail->Encoding = 'base64'; // 使用base64加密邮箱和密码 //Recipients $mail->setFrom('[email protected]', 'Mailer'); //发件人邮件地址 $mail->addAddress('[email protected]', 'Joe User'); // 增加一个收件人 $mail->addAddress('[email protected]'); // 再增加一个收件人,名称是可选的 // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body in bold!'; $mail->send(); } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; $link=mysql_connect('localhost','root','root'); mysql_select_db($link,$dbname); mysql_query("set names utf8"); while (true) { $sql="select * from tast_list where status = 0 order by task_id asc limit 5"; $res=mysql_query($sql); $mailList=[]; while ($row=mysql_fetch_assoc($res)) { $mailList[]=$row; if (empty($mailList)) { break; }else{ foreach ($mailList as $key => $value) { if (sendMail ("smtp.aliyun.com","[email protected]", "aliemail123","aliyun", $v['email'], 'sina', "php+mysql模拟队列发送邮件课程",file_get_contents( "new_course.html" ) )){ mysql_query( "UPDATE task_list SET status = 1 WHERE task_id =". Svalue['taskid'] ); sleep(3);
  • socket_wsaprotocol_info_export
  • socket_wsaprotocol_info_import
  • socket_wsaprotocol_info_release
  • cURL(*)
  • curl_setopt
  • Event(*)
  • Gearman
  • Gopher
  • Gupnp
  • Hyperwave API(过时)
  • LDAP(+)
  • Memcache
  • Memcached(+)
  • mqseries
  • ScoutAPM
  • Stomp
  • SVN(试验性的)
  • TCP扩展
  • Varnish
  • YP/NIS
  • 0MQ(ZeroMQ、ZMQ)消息系统
  • 0mq例子
  • ZooKeeper
  • 搜索引擎扩展
  • mnoGoSearch
  • Sphinx
  • Swish(实验性)
  • 针对服务器的扩展
  • Apache
  • FastCGI 进程管理器
  • NSAPI
  • Session 扩展
  • Msession
  • Sessions
  • Session PgSQL
  • BBCode
  • CommonMark(markdown解析)
  • cmark函数
  • cmark类
  • Parser
  • IVisitor接口
  • Node基类与接口
  • Document
  • Heading(#)
  • Paragraph
  • BlockQuote
  • BulletList
  • OrderedList
  • Strong
  • Emphasis
  • ThematicBreak
  • SoftBreak
  • LineBreak
  • CodeBlock
  • HTMLBlock
  • HTMLInline
  • Image
  • CustomBlock
  • CustomInline
  • Parle
  • PCRE( 核心)
  • POSIX Regex
  • ssdeep
  • 字符串(核心)
  • 变量与类型相关扩展
  • 数组(核心)
  • 类/对象(核心)
  • Classkit(未维护)
  • Ctype
  • Filter扩展
  • 过滤器函数
  • 函数处理(核心)
  • quickhash扩展
  • 反射扩展(核心)
  • Variable handling(核心)
  • Web 服务
  • OAuth
  • SCA(实验性)
  • XML-RPC(实验性)
  • Windows 专用扩展
  • 额外补充:Wscript
  • win32service
  • win32ps(停止更新且被移除)
  • XML 操作(也可以是html)
  • libxml(内置 默认开启)
  • DOM(内置,默认开启)
  • xml介绍
  • 扩展类与函数
  • DOMNode
  • DOMDocument(最重要)
  • DOMAttr
  • DOMCharacterData
  • DOMText(文本节点)
  • DOMCdataSection
  • DOMComment(节点注释)
  • DOMDocumentFragment
  • DOMDocumentType
  • DOMElement
  • DOMEntity
  • DOMEntityReference
  • DOMNotation
  • DOMProcessingInstruction
  • DOMXPath
  • DOMException
  • DOMImplementation
  • DOMNamedNodeMap
  • DOMNodeList
  • SimpleXML(内置,5.12+默认开启)
  • XMLReader(5.1+内置默认开启 用于处理大型XML文档)
  • XMLWriter(5.1+内置默认开启 处理大型XML文档)
  • SDO(停止维护)
  • SDO-DAS-Relational(试验性的)
  • SDO DAS XML
  • XMLDiff
  • XML 解析器(Expat 解析器 默认开启)
  • XSL(内置)
  • 图形用户界面(GUI) 扩展
  • PHP SPL(PHP 标准库)
  • SplDoublyLinkedList(双向链表)
  • SplStack(栈 先进后出)
  • SplQueue(队列)
  • SplHeap(堆)
  • SplMaxHeap(最大堆)
  • SplMinHeap(最小堆)
  • SplPriorityQueue(堆之优先队列)
  • SplFixedArray(阵列【数组】)
  • SplObjectStorage(映射【对象存储】)
  • ArrayIterator
  • RecursiveArrayIterator(支持递归)
  • DirectoryIterator类
  • FilesystemIterator
  • GlobIterator
  • RecursiveDirectoryIterator
  • EmptyIterator
  • IteratorIterator
  • AppendIterator
  • CachingIterator
  • RecursiveCachingIterator
  • FilterIterator(遍历并过滤出不想要的值)
  • CallbackFilterIterator
  • RecursiveCallbackFilterIterator
  • RecursiveFilterIterator
  • ParentIterator
  • RegexIterator
  • RecursiveRegexIterator
  • InfiniteIterator
  • LimitIterator
  • NoRewindIterator
  • MultipleIterator
  • RecursiveIteratorIterator
  • RecursiveTreeIterator
  • SplFileInfo
  • SplFileObject
  • SplTempFileObject
  • 接口 interface
  • Countable
  • OuterIterator
  • RecursiveIterator
  • SeekableIterator
  • 各种类及接口
  • SplSubject
  • SplObserver
  • ArrayObject(将数组作为对象操作)
  • SPL 函数
  • 预定义接口
  • Traversable(遍历)接口
  • Iterator(迭代器)接口
  • IteratorAggregate(聚合式迭代器)接口
  • ArrayAccess(数组式访问)接口
  • Serializable 序列化接口
  • JsonSerializable
  • Closure 匿名函数(闭包)类
  • Generator生成器类
  • 生成器(php5.5+)
  • yield
  • 一、反射(reflection)类
  • 二、Reflector 接口
  • ReflectionClass 类报告了一个类的有关信息。
  • ReflectionObject 类报告了一个对象(object)的相关信息。
  • ReflectionFunctionAbstract
  • ReflectionMethod 类报告了一个方法的有关信息
  • ReflectionFunction 类报告了一个函数的有关信息。
  • ReflectionParameter 获取函数或方法参数的相关信息
  • ReflectionProperty 类报告了类的属性的相关信息。
  • ReflectionClassConstant类报告有关类常量的信息。
  • ReflectionZendExtension 类返回Zend扩展相关信息
  • ReflectionExtension 报告了一个扩展(extension)的有关信息。
  • 三、ReflectionGenerator类用于获取生成器的信息
  • 四、ReflectionType 类用于获取函数、类方法的参数或者返回值的类型。
  • 五、反射的应用场景
  • phpRedis
  • API详细
  • redis DB 概念:
  • 通用命令:rawCommand
  • Connection
  • Server
  • string
  • 流streams
  • Geocoding 地理位置
  • lua脚本
  • Introspection 自我检测
  • biMap
  • php-redis 操作类 封装
  • redis 队列解决秒杀解决超卖:
  • swoole+框架笔记
  • 安装及常用Cli操作
  • 4种回调函数的写法
  • easyswoole
  • Linux+Nginx
  • linux
  • 开源网站镜像及修改yum源
  • 下载linux
  • Liunx中安装PHP7.4 的三种方法(Centos8)
  • yum安装
  • 源码编译安装
  • LNMP一键安装
  • 查看linux版本号
  • 设置全局环境变量
  • 查看php.ini必须存放的位置
  • 防火墙与端口开放
  • nohup 后台运行命令
  • linux 查看nginx,php-fpm运行用户及用户组
  • CentOS中执行yum update时报错
  • 关闭防火墙
  • 查看端口是否被占用
  • 查看文件夹大小
  • nginx相关
  • 一个典型的nginx配置
  • nginx关于多个项目的配置(易于管理)
  • nginx.config配置文件的结构
  • 1、events
  • 2、http
  • nginx的location配置详解
  • Nginx相关命令
  • Nginx安装
  • 配置伪静态
  • 为静态配置例子
  • apache
  • nginx
  • pathinfo模式
  • Shell脚本
  • shell 语言中 0 代表 true,0 以外的值代表 false。
  • shell字符串
  • shell数组
  • shell注释
  • 向Shell脚内传递参数
  • 显示命令执行结果
  • printf
  • test 命令
  • 流程控制与循环
  • while
  • until
  • break和continue
  • select 结构
  • shell函数
  • shell函数的全局变量和局部变量
  • 将shell输出写入文件中(输出重定向)
  • Shell脚本中调用另一个Shell脚本的三种方式
  • PHP实现定时任务的五种方法
  • ab压力测试
  • opcache
  • memcache
  • php操作
  • 数据库锁机制
  • 数据库设计
  • 字段类型的选择
  • SET FOREIGN_KEY_CHECKS
  • 字符集与乱码
  • SQL插入 去除重复记录的实现
  • nginx 主从配置
  • nginx 负载均衡的配置
  • 手动搭建Redis集群和MySQL主从同步(非Docker)
  • Redis Cluster集群
  • mysql主从同步
  • 用安卓手机搭建 web 服务器
  • url重写
  • 大流量高并发解决方案
  • RBAC0
  • RBAC1(角色上下级分层)
  • RBAC2(用户角色限约束)
  • RBAC3
  • Rbac.class.php
  • Rbac2
  • Auth.class.php
  • fastadmin Auth
  • tree1
  • ABAC 基于属性的访问控制
  • 总结:SAAS后台权限设计案例分析
  • casbin-权限管理框架
  • casbinAPI
  • casbin管理API
  • RBAC API
  • Think-Casbin
  • 单点登录(SSO)
  • OAuth授权
  • OAuth 2.0 的四种方式
  • 例子:第三方登录
  • 微服务架构下的统一身份认证和授权
  • 漏洞挖掘的思路
  • XSS 反射型漏洞
  • XSS 存储型漏洞
  • xss过滤
  • HTML Purifier文档
  • class规则
  • AutoFormat
  • Cache
  • Filter
  • Output
  • 嵌入YouTube视频
  • 加快HTML净化器的速度
  • URI过滤器
  • xss例子
  • 本地包含与远程包含
  • sql注入
  • information_schema
  • sql注入的分类
  • CSRF 跨站请求伪造
  • 计动态函数执行与匿名函数执行
  • unserialize反序列化漏洞
  • 覆盖变量漏洞
  • 文件管理漏洞
  • 文件上传漏洞
  • URL编码对照表
  • 前端、移动端
  • html5
  • meta标签
  • flex布局
  • javascript
  • jquery
  • on事件无效:
  • jquery自定义事件
  • select
  • checkbox
  • radio
  • js正则相关
  • js中判断某字符串含有某字符出现的次数
  • js匹配指定字符
  • $.getjson方法配合在url上传递callback=?参数,实现跨域
  • pajax入门
  • jquery的extend插件制作
  • jquery的兼容
  • jquery的连续调用:
  • $ 和 jQuery 及 $() 的区别
  • 页面响应顺序及$(function(){})等使用
  • 匿名函数:
  • 获取js对象所有方法
  • dom加载
  • ES6函数写法
  • ES6中如何导入和导出模块
  • 数组的 交集 差集 补集 并集
  • phantomjs
  • js数组的map()方法操作json数组
  • js精确计算CalcEval 【价格计算】 浮点计算
  • js精确计算2
  • js数组与对象的遍历
  • bootstrap
  • class速查
  • 常见data属性
  • data-toggle与data-target的作用
  • bootstrapTable
  • 数据格式(json)
  • 用法(row:行,column:列)
  • Bootstrap-table使用footerFormatter做统计列功能
  • JQuery-Jquery的TreeGrid插件
  • 服务器端分页
  • 合并单元格1
  • 合并单元格2
  • 合并单元格3
  • 合并单元格4
  • 合并单元格5(插件)
  • 添加行,修改行、扩展行数据
  • PhpSpreadsheet
  • 会员 数据库表设计
  • API接口
  • API接口设计
  • json转化
  • app接口
  • 三方插件库
  • 检测移动设备(包括平板电脑)
  • curl封装
  • Websocket
  • 与谷歌浏览器交互
  • Crontab管理器
  • 实用小函数
  • PHP操作Excel
  • SSL证书
  • sublime Emmet的快捷语法
  • 免费翻译接口
  • 架构师必须知道的26项PHP安全实践
  • 个人支付平台
  • RPC(远程调用)及框架
  •