@devon4ts/mailer v6.0.0-0
devon4ts
devonfw is a platform which provides solutions to building business applications which combine best-in-class frameworks and libraries as well as industry proven practices and code conventions. devonfw is 100% Open Source (Apache License version 2.0) since the beginning of 2018.
devon4ts is the NodeJS stack of devonfw. It allows you to build business applications (backends) using NodeJS technology in a standardized way based on established best-practices.
devon4ts mailer
This package contains the devon4ts mailer module. This module allows you to send emails in your devon4ts application in a easy way.
Usage
Installation
To start using @devon4ts/mailer
you just need to import the MailerModule
:
@Module({
imports: [
MailerModule.register({
mailOptions: {
host: 'localhost',
port: 1025,
secure: false,
tls: {
rejectUnauthorized: false,
},
},
emailFrom: 'noreply@example.com',
hbsOptions: {
templatesDir: join(__dirname, '../..', 'assets/templates/views'),
partialsDir: join(__dirname, '../..', 'assets/templates/partials'),
helpers: [],
},
}),
],
controllers: [],
providers: [],
})
export class AppModule {}
You can also use the asynchronous configuration:
@Module({
imports: [
MailerModule.registerAsync({
useFactory: (config: AppConfig) => config.mailer,
inject: [AppConfig],
}),
],
controllers: [],
providers: [],
})
export class AppModule {}
Usage
Frist, inject the MailerService:
@Injectable()
export class AppService {
constructor(mailer: MailerService) {}
}
And then use the MailerService
methods:
Send a plain email:
mailer.sendPlainMail(to, subject, mailContent);
Send a mail based on a template:
mailer.sendTemplateMail(to, subject, templateName, emailData, hbsOptions);
Add an handlebars template:
mailer.addTemplate(name, template, options);
Register an handlebars partial:
mailer.registerPartial(name, partial);
Register an handlebars helper:
mailer.registerHelper(name, helper);
Code of conduct
Visit code of conduct document.
Contributing guide
Visit contributing guide document.
Key Principles
Visit key principles document.