Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 3861f88

Browse files
committed
Merge branch 'develop' of https://github.com/tassiLuca/ChainVote into develop
2 parents 4932aef + 65325dd commit 3861f88

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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));

docs/report-asw/report.tex

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
\subtitle{(v. \version)}
1515

1616
\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}
1818
\and
1919
Luca Rubboli \\ \emailaddr{luca.rubboli2@studio.unibo.it} \\ Matr. \texttt{1083742}
2020
\and
@@ -567,8 +567,20 @@ \subsubsection{Rate limiter}
567567
\end{figure}
568568

569569
\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}
570583

571-
\todo{Fill mailer}
572584

573585
\subsubsection{Routes}
574586

0 commit comments

Comments
 (0)