tachybase_todo/packages/plugins/notifications/src/models/NotificationService.ts
chenos 883f1e6fd1
fix: eslint (#1759)
* fix: eslint

* fix: eslint --fix

* fix: changelog
2023-04-25 13:12:14 +08:00

27 lines
599 B
TypeScript

import { Model } from '@nocobase/database';
import nodemailer from 'nodemailer';
export class NotificationService extends Model {
[key: string]: any;
static createTransport = nodemailer.createTransport;
private _transporter = null;
get transporter() {
if (this._transporter) {
return this._transporter;
}
return (this._transporter = NotificationService.createTransport(this.options));
}
async send(options) {
const { from } = this.options;
const mailOptions = {
from,
...options,
};
return this.transporter.sendMail(mailOptions);
}
}