Skip to content

Commit

Permalink
Merge pull request #114 from ReflectionsProjections/dev/alex/html-ema…
Browse files Browse the repository at this point in the history
…il-function

html email function + static templates
  • Loading branch information
AydanPirani authored Jul 31, 2024
2 parents 5397229 + 7921a5b commit 94fd5c8
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"mongodb-memory-server": "^9.3.0",
"mongoose": "^8.2.3",
"morgan": "^1.10.0",
"mustache": "^4.2.0",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
"ts-node": "^10.9.2",
Expand Down
27 changes: 27 additions & 0 deletions src/services/ses/ses-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,30 @@ export function sendEmail(
})
.promise();
}

export function sendHTMLEmail(
emailId: string,
subject: string,
emailHtml: string
): Promise<AWS.SES.SendEmailResponse> {
return ses
.sendEmail({
Destination: {
ToAddresses: [emailId],
},
Message: {
Body: {
Html: {
Data: emailHtml,
},
},
Subject: {
Data: subject,
},
},
Source: Config.OUTGOING_EMAIL_ADDRESSES.Enum[
"[email protected]"
],
})
.promise();
}
52 changes: 52 additions & 0 deletions src/templates/templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const templates = {
SPONSOR_VERIFICATION: `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verification Code</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 50vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #f7f7f7;
}
.container {
background-color: #ffffff;
padding: 20px 40px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 10px;
text-align: center;
}
h1 {
font-size: 24px;
color: #333333;
margin-bottom: 10px;
}
.code {
font-size: 32px;
font-weight: bold;
color: #e74c3c;
letter-spacing: 2px;
background-color: #f2f2f2;
padding: 10px 20px;
border-radius: 5px;
display: inline-block;
}
</style>
</head>
<body>
<div class="container">
<h1>Here is your verification code:</h1>
<div class="code">{{code}}</div>
</div>
</body>
</html>`,
};

export default templates;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6167,6 +6167,11 @@ [email protected], ms@^2.1.1:
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

mustache@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64"
integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
Expand Down

0 comments on commit 94fd5c8

Please sign in to comment.