This repository was archived by the owner on May 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ import nodemailer from 'nodemailer' ;
2
+ import fs from "fs" ;
3
+
4
+ const path = "/run/secrets/google_api_secret" ;
5
+ const secretValue = fs . readFileSync ( path , 'utf8' ) . trim ( ) ;
6
+
7
+ const config = {
8
+ service : 'gmail' ,
9
+ auth : {
10
+ user : "chainvote.01@gmail.com" ,
11
+ pass : secretValue
12
+ }
13
+ }
14
+
15
+ export default nodemailer . createTransport ( config ) ;
Original file line number Diff line number Diff line change
1
+
2
+ import mailer from "../configs/mailer.config" ;
3
+
4
+
5
+ // other parts of the code
6
+
7
+ const message = {
8
+ from : 'ChainVote' ,
9
+ to : emailToSend ,
10
+ subject : 'Title of the email' ,
11
+ html : `
12
+ Some HTML content to append to the mail
13
+ `
14
+ } ;
15
+
16
+ await mailer . sendMail ( message ) . catch ( ( error : any ) => next ( error ) ) ;
Original file line number Diff line number Diff line change 14
14
\subtitle {(v. \version )}
15
15
16
16
\author {
17
- Giovanni Antonioni \\ \emailaddr {giovanni.antonioni2@studio.unibo.it} \\ Matr. \texttt {xxxx }
17
+ Giovanni Antonioni \\ \emailaddr {giovanni.antonioni2@studio.unibo.it} \\ Matr. \texttt {001083764 }
18
18
\and
19
19
Luca Rubboli \\ \emailaddr {luca.rubboli2@studio.unibo.it} \\ Matr. \texttt {1083742 }
20
20
\and
@@ -567,8 +567,20 @@ \subsubsection{Rate limiter}
567
567
\end {figure }
568
568
569
569
\subsubsection {Mailer }
570
+ The system can send emails to the user by the means of a mailer component configured inside the API server.
571
+ We use a custom gmail account which credentials are passed using a docker secret on the initialization of the container during the deployment phase.
572
+ \jsimport [
573
+ caption={The mailer component},
574
+ label={lst:mailer}
575
+ ]{listings/mailer-config.ts}
576
+
577
+ When needed the mailer can be used in the code as follows:
578
+
579
+ \jsimport [
580
+ caption={An example of how to use the mailer component},
581
+ label={lst:mailer-usage}
582
+ ]{listings/mailer-usage.ts}
570
583
571
- \todo {Fill mailer}
572
584
573
585
\subsubsection {Routes }
574
586
You can’t perform that action at this time.
0 commit comments