-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed the email_template.html to follow the {{}} convention
added an email_template.txt as an eqivelent for mail resivers that block html added an test for nodemailer to check if the smpt clinet is working changed the send-mails that it loads the templates and inputs and replaces it with the text and name added an tempory test befor the socket handelers for the smtp clent compose-messages.ts Added send TODO has to get the Name of the email recever
- Loading branch information
Showing
5 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Hallo {{receiver_name}}, | ||
|
||
{{text}} | ||
|
||
Regards, | ||
PHT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { nodemailer } from 'nodemailer'; | ||
import * as env from '../../../env'; | ||
import fs from "fs"; | ||
|
||
export async function sendEmail(client: nodemailer.Transport, destinationAddress: string, emailBody: string, emailSubject: string) { | ||
export async function sendEmail(client: nodemailer.Transport, destinationAddress: string, Text: string, receiver_name: string, emailSubject: string) { | ||
// create the email HTML body from the template | ||
let emailBodyHTML = fs.readFileSync("./src/components/socket/domains/email_template.html", "utf8"); | ||
emailBodyHTML = emailBodyHTML.replace(/{{receiver_name}}/g, receiver_name ); | ||
emailBodyHTML = emailBodyHTML.replace(/{{text}}/g, Text); | ||
// create the email plain text body from the template | ||
let emailBodyPlain = fs.readFileSync("./src/components/socket/domains/email_template.txt", "utf8"); | ||
emailBodyPlain = emailBodyPlain.replace(/{{receiver_name}}/g, receiver_name ); | ||
emailBodyPlain = emailBodyPlain.replace(/{{text}}/g, Text); | ||
// send the email | ||
await client.sendMail({ | ||
from: env.default.smtpMailFrom, // sender address | ||
to: destinationAddress, // list of receivers | ||
subject: emailSubject, // Subject line | ||
text: emailBody, // plain text body | ||
html: emailBody, // html body | ||
text: emailBodyPlain, // plain text body | ||
html: emailBodyHTML, // html body | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters