File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import nodemailer from 'nodemailer' ;
2+
3+ export class MailService {
4+ private transporter = nodemailer . createTransport ( {
5+ host : process . env . SMTP_HOST ,
6+ port : parseInt ( process . env . SMTP_PORT as string , 10 ) ,
7+ secure : process . env . SMTP_SECURE === 'true' ,
8+ auth : {
9+ user : process . env . SMTP_USER ,
10+ pass : process . env . SMTP_PASS
11+ }
12+ } ) ;
13+
14+ async sendVerificationEmail ( email : string , token : string ) {
15+ const url = `${ process . env . FRONTEND_URL } /confirm-email?token=${ token } ` ;
16+ await this . transporter . sendMail ( {
17+ from : process . env . FROM_EMAIL ,
18+ to : email ,
19+ subject : 'Verify your email' ,
20+ text : `Click to verify your email: ${ url } `
21+ } ) ;
22+ }
23+
24+ async sendPasswordResetEmail ( email : string , token : string ) {
25+ const url = `${ process . env . FRONTEND_URL } /reset-password?token=${ token } ` ;
26+ await this . transporter . sendMail ( {
27+ from : process . env . FROM_EMAIL ,
28+ to : email ,
29+ subject : 'Reset your password' ,
30+ text : `Reset your password: ${ url } `
31+ } ) ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments