mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: remove Webpack and depend on nodemon. feat: refactoring expenses. feat: optimize system users with caching. feat: architecture tenant optimize.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import Mustache from 'mustache';
|
|
import { Container } from 'typedi';
|
|
|
|
export default class SubscriptionMailMessages {
|
|
/**
|
|
* Send license code to the given mail address.
|
|
* @param {string} licenseCode
|
|
* @param {email} email
|
|
*/
|
|
public async sendMailLicense(licenseCode: string, email: string) {
|
|
const Logger = Container.get('logger');
|
|
const Mail = Container.get('mail');
|
|
|
|
const filePath = path.join(global.__root, 'views/mail/LicenseReceive.html');
|
|
const template = fs.readFileSync(filePath, 'utf8');
|
|
const rendered = Mustache.render(template, { licenseCode });
|
|
|
|
const mailOptions = {
|
|
to: email,
|
|
from: `${process.env.MAIL_FROM_NAME} ${process.env.MAIL_FROM_ADDRESS}`,
|
|
subject: 'Bigcapital License',
|
|
html: rendered,
|
|
};
|
|
return new Promise((resolve, reject) => {
|
|
Mail.sendMail(mailOptions, (error) => {
|
|
if (error) {
|
|
reject(error);
|
|
return;
|
|
}
|
|
resolve();
|
|
});
|
|
});
|
|
}
|
|
} |