-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
915aa39
commit 2b2e131
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
services/standard-space/main/default/services/email.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2024-07-30 13:43:46 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2024-07-30 13:49:42 | ||
* @Description: | ||
*/ | ||
"use strict"; | ||
/** | ||
* @typedef {import('moleculer').Context} Context Moleculer's Context | ||
*/ | ||
module.exports = { | ||
name: 'email', | ||
namespace: "steedos", | ||
/** | ||
* Settings | ||
*/ | ||
settings: { | ||
|
||
}, | ||
|
||
/** | ||
* Dependencies | ||
*/ | ||
dependencies: [], | ||
|
||
/** | ||
* Actions | ||
*/ | ||
actions: { | ||
send: { | ||
params: { | ||
from: { type: "string", optional: true }, | ||
to: { type: "string", optional: true }, | ||
subject: { type: "string", optional: true }, | ||
body: { type: "string" }, | ||
}, | ||
async handler(ctx) { | ||
const options = ctx.params | ||
try { | ||
Fiber(function () { | ||
MailQueue.send({ | ||
from: options.from, | ||
to: options.to, | ||
subject: options.subject, | ||
html: options.body, | ||
}); | ||
}).run(); | ||
} catch (error) { | ||
console.error('发送邮件失败:', error); | ||
} | ||
} | ||
}, | ||
} | ||
}; |