{"id":68,"date":"2026-10-28T12:00:40","date_gmt":"2026-10-28T20:00:40","guid":{"rendered":"\/?p=68"},"modified":"2026-10-28T12:00:40","modified_gmt":"2026-10-28T20:00:40","slug":"post-mvrl6u4h","status":"publish","type":"post","link":"https:\/\/www.woiov.cn\/?p=68","title":{"rendered":"v7.20.4 \u5ba1\u8ba1\u65e5\u62a5\uff1a\u96f6\u4f9d\u8d56\u624b\u6413 SMTP\uff0c\u516d\u4e2a\u5751\u4e00\u4e2a\u90fd\u6ca1\u5c11"},"content":{"rendered":"<p>\u5ba1\u8ba1\u65e5\u5fd7\u6700\u5927\u7684\u95ee\u9898\u662f\uff1a\u5b83\u4e00\u76f4\u5b58\u5728\uff0c\u4f46\u6ca1\u4eba\u4f1a\u4e3b\u52a8\u53bb\u770b\u3002<\/p>\n<p>\u72f8\u82b1\u4e91\u7684\u5ba1\u8ba1\u8868\u4ece v6 \u8d77\u5c31\u5728\u8bb0\u2014\u2014\u8c01\u6539\u4e86\u7528\u6237\u3001\u8c01\u52a8\u4e86\u5bb9\u5668\u3001\u8c01\u89e6\u53d1\u4e86\u91cd\u542f\u3002\u6570\u636e\u662f\u9f50\u7684\uff0c\u53ef\u5b83\u53ea\u5728\u540e\u53f0\u9875\u9762\u91cc\u5806\u7740\uff0c\u7b49\u7740\u4f60\u53bb\u7ffb\u3002\u800c\u771f\u6b63\u9700\u8981\u5b83\u7684\u65f6\u523b\uff0c\u5f80\u5f80\u662f\u4f60<strong>\u4e0d\u60f3\u5f00\u7535\u8111<\/strong>\u7684\u65f6\u523b\uff1a\u51cc\u6668\u4e09\u70b9\u6709\u4eba\u52a8\u4e86\u67d0\u4e2a\u5bb9\u5668\uff0c\u7b2c\u4e8c\u5929\u4f60\u5728\u8def\u4e0a\uff0c\u53ea\u60f3\u7528\u624b\u673a\u770b\u4e00\u773c&#8221;\u6628\u5929\u5230\u5e95\u53d1\u751f\u4e86\u4ec0\u4e48\u4e8b&#8221;\u3002<\/p>\n<p>v7.20.4 \u505a\u7684\u5c31\u662f\u8fd9\u4ef6\u4e8b\uff1a\u6bcf\u5929 09:00\uff0c\u4e00\u5c01 HTML \u90ae\u4ef6\uff0c\u628a\u8fd1 24 \u5c0f\u65f6\u7684\u5ba1\u8ba1\u8bb0\u5f55\u6c47\u603b\u597d\uff0c\u53d1\u5230 <code>contact.email<\/code>\u3002<\/p>\n<h3>\u4e00\u3001\u4e09\u6761\u4e0d\u80fd\u7834\u7684\u7ea6\u675f<\/h3>\n<p>\u5728\u52a8\u624b\u4e4b\u524d\u5148\u5b9a\u4e86\u4e09\u6761\u7ebf\uff0c\u540e\u9762\u7684\u6240\u6709\u5b9e\u73b0\u90fd\u662f\u56f4\u7ed5\u5b83\u4eec\u505a\u7684\u53d6\u820d\uff1a<\/p>\n<p>1. <strong>\u4e0d\u5f15\u4f9d\u8d56<\/strong>\u3002<code>node_modules<\/code> \u5df2\u7ecf\u591f\u91cd\u4e86\uff0c\u800c\u8fd9\u4e2a\u9879\u76ee\u7684\u90ae\u4ef6\u6a21\u5757\u4ece\u505a\u6ce8\u518c\u9a8c\u8bc1\u7801\u90a3\u4e00\u7248\u5f00\u59cb\u5c31\u662f\u96f6\u4f9d\u8d56\u2014\u2014\u81ea\u5df1\u5f00 TLS socket \u8bf4 SMTP \u534f\u8bae\u3002<\/p>\n<p>2. <strong>\u5931\u8d25\u4e0d\u80fd\u5f71\u54cd\u4e3b\u6d41\u7a0b<\/strong>\u3002\u65e5\u62a5\u662f\u540e\u53f0\u4efb\u52a1\uff0c\u5b83\u574f\u4e86\uff0c\u7528\u6237\u4e0b\u5355\u3001\u5f00\u673a\u3001\u8fde\u7ec8\u7aef\u90fd\u4e0d\u80fd\u53d7\u4efb\u4f55\u5f71\u54cd\u3002<\/p>\n<p>3. <strong>\u540c\u4e00\u5929\u4e0d\u80fd\u53d1\u4e24\u5c01<\/strong>\u3002\u91cd\u590d\u7684\u62a5\u8868\u6bd4\u6ca1\u6709\u62a5\u8868\u66f4\u70e6\u4eba\u3002<\/p>\n<h3>\u4e8c\u3001\u5b9a\u65f6\u4e3a\u4ec0\u4e48\u4e0d\u7528 node-cron<\/h3>\n<p>\u9700\u6c42\u53ea\u662f&#8221;\u6bcf\u5929\u4e00\u6b21&#8221;\uff0c\u4e3a\u6b64\u52a0\u4e00\u4e2a cron \u5e93\u4e0d\u5212\u7b97\u3002\u5b9e\u9645\u5199\u6cd5\u662f\uff1a\u6bcf 30 \u5206\u949f\u9192\u4e00\u6b21\uff0c\u770b\u4e00\u773c\u73b0\u5728\u51e0\u70b9\u3002<\/p>\n<pre class=\"wp-block-code\"><code>\nsetInterval(async () =&gt; {\n  const now = new Date()\n  if (now.getHours() !== 9) return          \/\/ \u672c\u5730 9 \u70b9\n  const today = now.toISOString().slice(0, 10)   \/\/ UTC \u65e5\u671f\n  const st = loadAuditMailState()\n  if (st.lastSent === today) return          \/\/ \u53bb\u91cd\u9760\u72b6\u6001\u6587\u4ef6\n  const r = await sendAuditDigest(24)\n  saveAuditMailState({ lastSent: today, lastResult: r })\n}, 30 * 60 * 1000)\n<\/code><\/pre>\n<p>\u4e09\u4e2a\u7ec6\u8282\u503c\u5f97\u8bf4\uff1a<\/p>\n<p><strong>\u53bb\u91cd\u9760\u4e00\u4e2a\u72b6\u6001\u6587\u4ef6<\/strong>\uff0c\u4e0d\u662f\u5185\u5b58\u53d8\u91cf\u3002<code>data\/audit-mail-state.json<\/code> \u91cc\u5b58 <code>lastSent<\/code>\uff0c\u8fdb\u7a0b\u91cd\u542f\u4e4b\u540e\u7167\u6837\u77e5\u9053\u4eca\u5929\u53d1\u8fc7\u6ca1\u6709\u2014\u2014\u5185\u5b58\u53d8\u91cf\u5728\u5bb9\u5668\u91cd\u542f\u9762\u524d\u4e00\u6587\u4e0d\u503c\u3002<\/p>\n<p><strong>\u9996\u6b21\u90e8\u7f72\u4f1a\u591a\u4e00\u5c01<\/strong>\u3002\u5982\u679c\u72b6\u6001\u6587\u4ef6\u4e0d\u5b58\u5728\uff08\u65b0\u88c5\u7684\u673a\u5668\uff09\uff0c\u542f\u52a8 60 \u79d2\u540e\u5148\u8bd5\u53d1\u4e00\u5c01\u3002\u539f\u56e0\u5f88\u5b9e\u9645\uff1a\u4e0d\u7136\u4f60\u5f97\u7b49\u5230\u7b2c\u4e8c\u5929\u65e9\u4e0a 9 \u70b9\uff0c\u624d\u77e5\u9053 SMTP \u914d\u9519\u4e86\u6ca1\u6709\u3002<\/p>\n<p><strong>\u65f6\u533a\u662f\u4e2a\u5df2\u77e5\u53d6\u820d<\/strong>\u3002\u5224\u65ad&#8221;\u51e0\u70b9&#8221;\u7528\u672c\u5730\u5c0f\u65f6\uff0c\u53bb\u91cd\u952e\u7528 UTC \u65e5\u671f\u3002\u670d\u52a1\u5668\u662f UTC+8 \u7684\u65f6\u5019\u4e24\u8005\u4e00\u81f4\uff0c\u4e00\u5207\u6b63\u5e38\uff1b\u54ea\u5929\u6709\u4eba\u628a\u5bb9\u5668 TZ \u6539\u6210 UTC\uff0c\u8fd9\u5c01\u4fe1\u5c31\u4f1a\u5728\u5317\u4eac\u65f6\u95f4 17 \u70b9\u53d1\u51fa\u3002\u8fd9\u662f\u5199\u5728\u4ee3\u7801\u91cc\u7684\u53d6\u820d\uff0c\u4e0d\u662f\u6f0f\u6389\u7684 bug\u2014\u2014\u4f46\u5b83\u786e\u5b9e\u662f\u4e2a\u9700\u8981\u8bb0\u4f4f\u7684\u5751\u3002<\/p>\n<h3>\u4e09\u3001\u62a5\u8868\u957f\u4ec0\u4e48\u6837<\/h3>\n<p>\u7edf\u8ba1\u533a\u95f4\u3001\u603b\u6570\u3001\u5931\u8d25\u6570\uff0c\u7136\u540e\u6309\u7c7b\u578b\u548c\u6309\u7528\u6237\u5404\u4e00\u5f20\u8868\uff0c\u6700\u540e\u662f\u5931\u8d25\u660e\u7ec6\uff0c\u6700\u591a 30 \u6761\u3002\u6458\u8981\u90e8\u5206\u662f\u7eaf\u6587\u672c + HTML \u53cc\u4efd\u3002<\/p>\n<p>\u6709\u4e00\u4e2a\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u8fb9\u754c\uff1a<strong>\u8fd9\u4e2a\u65f6\u6bb5\u5982\u679c\u6ca1\u6709\u8bb0\u5f55\uff0c\u5c31\u4e0d\u53d1<\/strong>\u3002<\/p>\n<pre class=\"wp-block-code\"><code>\nif (!rows.length) return { ok: true, skipped: '\u8be5\u65f6\u6bb5\u65e0\u5ba1\u8ba1\u8bb0\u5f55' }\n<\/code><\/pre>\n<p>\u542c\u8d77\u6765\u7406\u6240\u5f53\u7136\uff0c\u4f46\u7b2c\u4e00\u7248\u6211\u4eec\u5dee\u70b9\u53d1\u4e86\u5c01&#8221;\u8bb0\u5f55\u6570 0\uff0c\u5931\u8d25 0&#8243;\u7684\u7a7a\u8868\u3002\u4e00\u5c01\u6bcf\u5929\u51c6\u65f6\u5230\u8fbe\u3001\u5185\u5bb9\u6c38\u8fdc\u662f\u96f6\u7684\u90ae\u4ef6\uff0c\u4e24\u5468\u4e4b\u540e\u5c31\u4f1a\u88ab\u6254\u8fdb\u5783\u573e\u7bb1\u2014\u2014\u800c\u5b83\u672c\u8be5\u662f\u5f02\u5e38\u4fe1\u53f7\u3002<\/p>\n<h3>\u56db\u3001\u624b\u6413 SMTP \u7684\u516d\u4e2a\u5751<\/h3>\n<p>\u8fd9\u662f\u6574\u4ef6\u4e8b\u91cc\u6700\u82b1\u65f6\u95f4\u7684\u5730\u65b9\u3002\u534f\u8bae\u672c\u8eab\u4e0d\u590d\u6742\uff0c\u96be\u7684\u662f\u90a3\u4e9b&#8221;\u6587\u6863\u91cc\u4e0d\u5199\u3001\u5931\u8d25\u65f6\u4e0d\u544a\u8bc9\u4f60\u539f\u56e0&#8221;\u7684\u7ec6\u8282\u3002<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>\u5751<\/th>\n<th>\u75c7\u72b6<\/th>\n<th>\u5904\u7406<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u591a\u884c\u5e94\u7b54<\/td>\n<td>\u4e00\u6b21 data \u4e8b\u4ef6\u5c31\u5f53\u5b8c\u6574\u56de\u590d\uff0cEHLO \u7684 <code>250-<\/code> \u7eed\u884c\u88ab\u8bef\u5224\u7ed3\u675f<\/td>\n<td>\u6309\u884c\u5207\uff0c\u6700\u540e\u4e00\u884c\u5339\u914d <code>^\\d{3} <\/code> \u624d\u7b97\u8bfb\u5b8c\u6574<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d\u6587\u4e3b\u9898<\/td>\n<td>\u5ba2\u6237\u7aef\u663e\u793a\u4e00\u4e32\u95ee\u53f7\u6216\u76f4\u63a5\u4e71\u7801<\/td>\n<td><code>Subject: =?UTF-8?B?<base64>?=<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u70b9\u586b\u5145<\/td>\n<td>\u6b63\u6587\u91cc\u6709\u4ee5 <code>.<\/code> \u5f00\u5934\u7684\u884c\uff0c\u670d\u52a1\u5668\u63d0\u524d\u5224\u5b9a DATA \u7ed3\u675f\uff0c\u4fe1\u88ab\u622a\u65ad<\/td>\n<td>\u884c\u9996 <code>.<\/code> \u5199\u6210 <code>..<\/code>\uff0c\u7ed3\u5c3e\u5355\u72ec\u4e00\u884c <code>.<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u53cc\u4f53\u88c1<\/td>\n<td>\u53ea\u53d1 HTML\uff0c\u90e8\u5206\u5ba2\u6237\u7aef\u663e\u793a\u7a7a\u767d<\/td>\n<td><code>multipart\/alternative<\/code>\uff0cplain \u5728\u524d\u3001HTML \u5728\u540e<\/td>\n<\/tr>\n<tr>\n<td>\u7f3a Message-ID<\/td>\n<td>\u5927\u91cf\u8fdb\u5783\u573e\u7bb1\uff0c\u4e14\u96be\u8ffd\u67e5<\/td>\n<td>\u8865 <code>Date<\/code>\uff08toUTCString\uff09\u4e0e <code>Message-ID: <ts@host><\/code><\/td>\n<\/tr>\n<tr>\n<td>465 \u4e0e 587<\/td>\n<td>587 \u7aef\u53e3\u76f4\u63a5\u4e0a TLS\uff0c\u63e1\u624b\u5931\u8d25<\/td>\n<td>465 \u9690\u5f0f TLS\uff1b587 \u5148\u660e\u6587 EHLO\uff0c\u89c1 STARTTLS \u518d\u5347\u7ea7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u5176\u4e2d&#8221;\u70b9\u586b\u5145&#8221;\u6700\u9634\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst safe = data.split('\\r\\n').map((l) =&gt; (l.startsWith('.') ? '.' + l : l)).join('\\r\\n')\nsocket.write(safe + '\\r\\n.\\r\\n')\n<\/code><\/pre>\n<p>\u4e0d\u8f6c\u4e49\u7684\u8bdd\uff0c\u6b63\u6587\u91cc\u4efb\u4f55\u4e00\u884c\u4ee5\u70b9\u5f00\u5934\uff0c\u670d\u52a1\u5668\u90fd\u4f1a\u8ba4\u4e3a\u4fe1\u5199\u5b8c\u4e86\u2014\u2014\u4f60\u7684\u90ae\u4ef6\u4f1a\u5728\u90a3\u53e5\u8bdd\u4e4b\u540e\u88ab\u6574\u9f50\u5730\u5207\u6389\uff0c\u800c\u4e14<strong>\u8fd4\u56de\u7801\u8fd8\u662f 250<\/strong>\u3002\u4f60\u4ee5\u4e3a\u53d1\u51fa\u53bb\u4e86\u3002<\/p>\n<p>\u591a\u884c\u5e94\u7b54\u90a3\u4e2a\u5751\u5219\u662f\u53e6\u4e00\u56de\u4e8b\uff1aSMTP \u7528 <code>250-<\/code> \u8868\u793a&#8221;\u8fd8\u6709\u4e0b\u4e00\u884c&#8221;\uff0c<code>250 <\/code> \u8868\u793a&#8221;\u5230\u6b64\u4e3a\u6b62&#8221;\u3002\u4e0d\u533a\u5206\u8fd9\u4e24\u79cd\uff0c<code>EHLO<\/code> \u4e4b\u540e\u62ff\u5230\u7684\u5c31\u662f\u4e00\u4e32\u534a\u622a\u6587\u672c\uff0c\u540e\u9762\u6240\u6709\u72b6\u6001\u5224\u65ad\u5168\u9519\u3002<\/p>\n<h3>\u4e94\u3001\u5b83\u503c\u591a\u5c11<\/h3>\n<p>\u8fd9\u5c01\u4fe1\u4e0d\u6f02\u4eae\u3002\u6ca1\u6709\u4eea\u8868\u76d8\u3001\u6ca1\u6709\u56fe\u8868\u3001\u6ca1\u6709\u5b9e\u65f6\u5237\u65b0\uff0c\u53ea\u662f\u4e00\u5c01\u6392\u7248\u6734\u7d20\u7684 HTML \u8868\u683c\u90ae\u4ef6\u3002<\/p>\n<p>\u4f46\u5b83\u6709\u4e00\u4e2a\u522b\u7684\u754c\u9762\u90fd\u6ca1\u6709\u7684\u6027\u8d28\uff1a<strong>\u5b83\u4f1a\u5728\u4f60\u4e0d\u4e3b\u52a8\u7684\u65f6\u5019\u51fa\u73b0<\/strong>\u3002<\/p>\n<p>\u76d1\u63a7\u7684\u4ef7\u503c\u4ece\u6765\u4e0d\u5728&#8221;\u80fd\u67e5\u5230&#8221;\uff0c\u800c\u5728&#8221;\u4e0d\u7528\u67e5\u4e5f\u77e5\u9053&#8221;\u3002\u5ba1\u8ba1\u8868\u5df2\u7ecf\u8bb0\u4e86\u51e0\u4e2a\u6708\uff0c\u771f\u6b63\u88ab\u4eba\u8bfb\u5b8c\u7684\u6b21\u6570\uff0c\u4e00\u53ea\u624b\u6570\u5f97\u8fc7\u6765\u3002\u73b0\u5728\u5b83\u6bcf\u5929\u65e9\u4e0a\u81ea\u5df1\u8d70\u8fc7\u6765\uff0c\u8bf4\u4e00\u53e5\u6628\u5929\u53d1\u751f\u4e86\u4ec0\u4e48\u3002<\/p>\n<p>\u4ee3\u4ef7\u662f\u4e00\u5c01\u90ae\u4ef6\u3001\u4e00\u4e2a\u72b6\u6001\u6587\u4ef6\u3001\u548c\u516d\u4e2a\u88ab\u534f\u8bae\u6559\u80b2\u8fc7\u7684\u591c\u665a\u3002\u8fd9\u4e70\u5356\u4e0d\u4e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5ba1\u8ba1\u65e5\u5fd7\u6700\u5927\u7684\u95ee\u9898\u662f\uff1a\u5b83\u4e00\u76f4\u5b58\u5728\uff0c\u4f46\u6ca1\u4eba\u4f1a\u4e3b\u52a8\u53bb\u770b\u3002 \u72f8\u82b1\u4e91\u7684\u5ba1\u8ba1\u8868\u4ece v6 \u8d77\u5c31\u5728\u8bb0\u2014\u2014\u8c01\u6539\u4e86\u7528\u6237\u3001\u8c01\u52a8\u4e86\u5bb9\u5668\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-cat-e68a80e69cafe697"],"_links":{"self":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":0,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}