fix(core): update
This commit is contained in:
44
ts/index.ts
Normal file
44
ts/index.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import * as plugins from './smartsmtp.plugins';
|
||||
|
||||
export interface ISmartSmtpOptions {
|
||||
smtpServer: string;
|
||||
smtpUser: string;
|
||||
smtpPassword: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use it to send mails via smtp
|
||||
*/
|
||||
export class Smartsmtp {
|
||||
public nodemailerTransport: plugins.nodemailer.Transporter;
|
||||
constructor(optionsArg: ISmartSmtpOptions) {
|
||||
this.nodemailerTransport = plugins.nodemailer.createTransport({
|
||||
host: optionsArg.smtpServer,
|
||||
port: 465,
|
||||
secure: true, // upgrade later with STARTTLS
|
||||
auth: {
|
||||
user: optionsArg.smtpUser,
|
||||
pass: optionsArg.smtpPassword
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a SmartMail
|
||||
*/
|
||||
public async sendSmartMail(
|
||||
smartmailArg: plugins.smartmail.Smartmail<any>,
|
||||
toArg: string,
|
||||
dataArg = {}
|
||||
) {
|
||||
const message = {
|
||||
from: smartmailArg.options.from,
|
||||
to: toArg,
|
||||
subject: smartmailArg.getSubject(dataArg),
|
||||
text: smartmailArg.getBody(dataArg),
|
||||
html: smartmailArg.getBody(dataArg)
|
||||
};
|
||||
const response = await this.nodemailerTransport.sendMail(message);
|
||||
return response;
|
||||
}
|
||||
}
|
13
ts/smartsmtp.plugins.ts
Normal file
13
ts/smartsmtp.plugins.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @pushrocks scope
|
||||
import * as smartmail from '@pushrocks/smartmail';
|
||||
|
||||
export {
|
||||
smartmail
|
||||
};
|
||||
|
||||
// third party scope
|
||||
import * as nodemailer from 'nodemailer';
|
||||
|
||||
export {
|
||||
nodemailer
|
||||
};
|
Reference in New Issue
Block a user