服务器有可升级包时发送邮件
中级
这是一个Engineering, DevOps, IT Ops, SecOps领域的自动化工作流,包含 7 个节点。主要使用 If, Ssh, Code, EmailSend, ScheduleTrigger 等节点。 服务器有可升级包时发送邮件
前置要求
- •无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"nodes": [
{
"id": "4ca55c6e-cf2e-4239-82a9-88d0a201e761",
"name": "列出可升级的软件包",
"type": "n8n-nodes-base.ssh",
"notes": "apt list --upgradable",
"position": [
-280,
0
],
"parameters": {
"command": "apt list --upgradable"
},
"credentials": {
"sshPassword": {
"id": "Ps31IKTeseWFlA0g",
"name": "SSH Password account"
}
},
"notesInFlow": true,
"typeVersion": 1,
"alwaysOutputData": false
},
{
"id": "ae1f0a55-31aa-494b-baa6-822dc606188e",
"name": "通过 SMTP 发送邮件",
"type": "n8n-nodes-base.emailSend",
"position": [
380,
0
],
"webhookId": "8073c571-b36f-4330-a510-ca2ff2924fbf",
"parameters": {
"html": "=The following packages can be updated on your server:\n\n{{ $json.htmlList }}\n\nPlease login and perform upgrade.",
"options": {},
"subject": "Server needs updates",
"toEmail": "change.me@example.com",
"fromEmail": "change.me@example.com"
},
"credentials": {
"smtp": {
"id": "uiNePdJaDng5a43S",
"name": "SMTP account"
}
},
"typeVersion": 2.1
},
{
"id": "e1d76671-d94c-40d5-9364-623db9319f11",
"name": "每日运行工作流",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-540,
0
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "ec4d722a-b88c-42da-971c-28ad5774596d",
"name": "格式化为 HTML 列表",
"type": "n8n-nodes-base.code",
"position": [
-60,
0
],
"parameters": {
"jsCode": "function formatStdoutAsHtmlList(stdoutData) {\n\n // Split the stdout into lines and map to HTML list items\n const htmlListItems = stdoutData.split('\\n').map((line) => {\n if (line.trim() && line !== \"Listing...\") { // Optionally skip empty lines or headers\n return `<li>${line.trim()}</li>`;\n }\n }).filter(item => item); // Remove any undefined items due to empty lines or skipped headers\n\n // Wrap the list items in a <ul> tag\n const htmlList = `<ul>${htmlListItems.join('')}</ul>`;\n\n // Return the formatted HTML list as part of an object\n return { \"htmlList\": htmlList };\n}\n\nreturn formatStdoutAsHtmlList($input.first().json.stdout);"
},
"typeVersion": 2
},
{
"id": "6f14eb02-c505-4f83-a5bb-68094e763fd9",
"name": "检查是否有更新",
"type": "n8n-nodes-base.if",
"position": [
140,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "db66d892-26fb-406c-a0ac-2e4b8a60310a",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.htmlList }}",
"rightValue": "<ul></ul>"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "3924c696-5b0e-4ae2-b2e2-435fed344028",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-740,
-180
],
"parameters": {
"width": 300,
"content": "## VPS 升级通知"
},
"typeVersion": 1
},
{
"id": "bb8ade2a-4ffe-4c79-91eb-55af568eb1b1",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
380,
-180
],
"parameters": {
"width": 300,
"content": "## 更新邮件地址"
},
"typeVersion": 1
}
],
"connections": {
"Format as HTML list": {
"main": [
[
{
"node": "Check if there are updates",
"type": "main",
"index": 0
}
]
]
},
"Run workflow every day": {
"main": [
[
{
"node": "List upgradable packages",
"type": "main",
"index": 0
}
]
]
},
"Send Email through SMTP": {
"main": [
[]
]
},
"List upgradable packages": {
"main": [
[
{
"node": "Format as HTML list",
"type": "main",
"index": 0
}
]
]
},
"Check if there are updates": {
"main": [
[
{
"node": "Send Email through SMTP",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工程, 开发运维, IT 运维, 安全运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
每15分钟检查VPS资源使用情况
每15分钟检查VPS资源使用情况
If
Ssh
Merge
+3
10 节点Hostinger
开发运维
Docker注册表清理工作流
Docker注册表清理工作流
Set
Ssh
Code
+6
16 节点Muzaffer AKYIL
工程
获取所有Scaleway服务器信息副本
通过动态筛选获取Scaleway服务器信息
If
Set
Code
+7
24 节点Pablo
工程
SSL到期提醒
使用SSL-Checker.io的SSL到期提醒
If
Gmail
Http Request
+3
12 节点Vishal Kumar
开发运维
n8n更新
使用 Telegram 审批系统自动化 Docker 容器更新
If
Set
Ssh
+6
27 节点Jaber Zare
开发运维
AIAutomationPro 高级错误处理与邮件通知 v1
集中式n8n错误管理系统,通过Gmail自动发送邮件警报
If
N8n
Set
+6
16 节点Daniel Ng
工程
工作流信息
难度等级
中级
节点数量7
分类4
节点类型6
作者
Hostinger
@hostingerHostinger aims to make online presence accessible to everyone worldwide – from developers to aspiring bloggers and business owners. With our fast hosting technology, AI-powered Website Builder, and easy-to-operate hPanel you can succeed online faster and easier.
外部链接
在 n8n.io 查看 →
分享此工作流