1.9.5 • Published 2 years ago
vitemail v1.9.5
Vitemail
Vitemail is a library for sending emails easily
Sections Breakdown
Installation
npm i vitemail
Usage
- Module Configuration
In your module file where you want to use it, provide your auth details to the authProvider method.
import { ViteMailModule } from "vitemail";
@Module({
imports: [
ViteMailModule.authProvider({
email: "example@gmail.com",
password: "*******",
}),
],
})
export class AppModule {}
- Service Configuration
In your service file where you want to use it.
import { ViteMailService } from "vitemail";
// At the constructor inject it like nany other third party service
constructor(private vitemailService: ViteMailService) { }
// service function example
async sendEmail(emailDto: any): Promise<any> {
try {
const response = await this.vitemailService.sendEmail({
sender: {
email: "sender@gmail.com",
name: "Test Sender"
},
receiver: {
email: "receiver@gmail.com",
name: "Test Receiver"
},
message: "Demo Testing",
subject: "Demo"
})
console.log(response)
}
catch (error) {}
}
- Types example
import { VitemailOptions } from "vitemail";
const options: VitemailOptions = {
// this is required for both the name and email
sender: {
email: "example@gmail.com",
name: "sender name",
},
// the name of the receiver is not required
receiver: {
email: "example@gmail.com",
name: "receiver",
},
message: "this is a message",
replyTo: "example2@gmail.com",
subject: "Testing",
cc: "example4@gmail.com", // the same applies with the bcc field
};