mirror of
https://github.com/Teamlinker/Teamlinker.git
synced 2025-06-03 03:00:17 +00:00
33 lines
860 B
TypeScript
33 lines
860 B
TypeScript
import * as nodemailer from "nodemailer"
|
|
import {IServer_Common_Config_Mail} from "../types/config";
|
|
|
|
let g_mail:Mail
|
|
export class Mail {
|
|
private transporter:nodemailer.Transporter
|
|
private config:IServer_Common_Config_Mail
|
|
constructor(config:IServer_Common_Config_Mail) {
|
|
g_mail=this;
|
|
this.config=config
|
|
this.transporter=nodemailer.createTransport({
|
|
host:config.host,
|
|
port:config.port,
|
|
secure:true,
|
|
auth:{
|
|
user:config.user,
|
|
pass:config.pass
|
|
}
|
|
})
|
|
}
|
|
async send(to:string,subject:string,content:string) {
|
|
await this.transporter.sendMail({
|
|
from:this.config.user,
|
|
to,
|
|
subject,
|
|
html:content
|
|
})
|
|
}
|
|
}
|
|
|
|
export function getMailInstance() {
|
|
return g_mail
|
|
} |