
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@pixelplex/mail-service
Advanced tools
Library for fast implementation of the functionality of sending email messages.
The sends messages them via email.
@pixelplex/mail-service to your applicationMailModule.forRoot from @pixelplex/mail-service
with specified gateways and optionsthis.mailSenderService.sendEmail('test@gmail.com', { htmlPath: htmlTemplatePath, plainPath: plainTextTemplatePath, subjectPath: subjectTemplatePath }, {year: 20}); where mailSenderService is MailSenderServiceCurrently supported gateways:
Didn't understand anything? Okay, let's see more details
The service uses Handlebars as template engine. So all your email templates should be prepared as handlebars templates.
For sending message your templates folder should include this files:
{name}.handlebars - body of your email where {name} is just your template name for email. For example welcome.handlebars for the welcome use email{name}.subject.handlebars - subject (title) of your email. You can use subject field to specify subject directly. It will override subjectPath{name}.plain.handlebars - subject (title) of your email. You can use plain field to specify plain directly. It will override plainPath# welcome.subject.handlebars Welcome, {{name}}! This is subject
# welcome.handlebars
<html>
<head></head>
<body>
<p>Welcome, {{name}}!</p>
<p>How are you?</p>
</body>
</html>
# welcome.plain.handlebars
<html>
<head></head>
<body>
<p>Welcome, {{name}}!</p>
<p>How are you?</p>
</body>
</html>
| Name | Description | Example |
|---|---|---|
| gateways | Array of gateways to send email | ['slack'] |
| customGateways | Array of custom gateways classes | [CustomGateway] |
| smtp.host | Mail gateway host address | smtp.gmail.com |
| smtp.port | Mail gateway port number | 586 |
| smtp.username | Mail gateway username | username |
| smtp.password | Mail gateway password | qh05780c2qcm034579 |
| *.sender | Mail sender address | postmail@pixelplex.io |
| slack.url | Hook URL in case you want to duplicate messages to Slack | https://hooks.slack.com |
| sendgrid.apiKey | Sendgrid api key | oiqur9823uiofhaoafoe |
1. Install npm package
yarn add @pixelplex/mail-service
2. Import MailModule in your module you'll send mail from:
import { Module } from '@nestjs/common';
import { MailModule } from '@pixelplex/mail-service';
import { AppService } from './app.service';
@Module({
controllers: [],
imports: [
MailModule.forRoot({
gateways: ['slack', 'smtp', 'console'],
slack: { url: 'hooks.slack.com' },
smtp: {
username: 'postmail@pixelplex.io',
sender: 'postmail@pixelplex.io',
host: 'smtp.ethereal.com',
port: 678,
password: 'password',
},
}),
],
providers: [AppService],
})
export class AppModule {}
3. Call sendEmail to send your mail:
import { Injectable } from '@nestjs/common';
import { MailSenderService } from '@pixelplex/mail-service';
@Injectable()
export class AppService {
constructor(private mailSenderService: MailSenderService) {}
async onModuleInit() {
this.mailSenderService.sendEmail(
'test@gmail.com',
// additionaly you can use plain: plainText, subject: subjectText to specify plain or subject directly
// if so, plainPath or subjectPath will be ignored
{ htmlPath: htmlTemplatePath, plainPath: plainTextTemplatePath, subjectPath: subjectTemplatePath },
{ year: 20 },
);
}
}
{year: 20} is the object with data which will used as payload data during processing your handlebars template.
To add custom gateways, provide class, that extends IGateway to customGateways options
@Injectable()
class CustomGateway implements IGateway {
async send(to: string, content: Content): Promise<void> {
console.log('this is custom gateway');
}
}
MailModule.forRoot({ customGateways: [CustomGateway] });
FAQs
Mail service
We found that @pixelplex/mail-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.