Skip to content

Commit

Permalink
Feat: Auto convert HTML to text
Browse files Browse the repository at this point in the history
  • Loading branch information
Gum-Joe committed Jul 23, 2024
1 parent 76d7613 commit 2757dea
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 5 deletions.
155 changes: 154 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/email/docsoc-mail-merge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ This library was generated with [Nx](https://nx.dev).
## Building

Run `nx build docsoc-mail-merge` to build the library.

## Plan
2 changes: 2 additions & 0 deletions packages/email/docsoc-mail-merge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"dependencies": {
"dotenv": "^16.4.5",
"html-to-text": "^9.0.5",
"nodemailer": "^6.9.14",
"tslib": "^2.3.0"
},
Expand All @@ -14,6 +15,7 @@
"devDependencies": {
"@types/chalk": "^2.2.0",
"@types/dotenv": "^8.2.0",
"@types/html-to-text": "^9.0.4",
"@types/nodemailer": "^6.4.15",
"@types/winston": "^2.4.4",
"ts-node": "^10.9.2"
Expand Down
5 changes: 2 additions & 3 deletions packages/email/docsoc-mail-merge/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ async function main() {
? process.env['DOCSOC_SENDER_EMAIL'] ?? '[email protected]'
: '[email protected]'
),
[],
['[email protected]'],
'Test email',
'<p>Test email</p>',
'Test email'
'<html><body>Test Email</body></html>',
);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/email/docsoc-mail-merge/src/mailer/mailer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import nodemailer from 'nodemailer';
import { EmailString, FromEmail } from '../util/types';
import { convert } from "html-to-text";

export default class Mailer {
constructor(
Expand All @@ -24,7 +25,7 @@ export default class Mailer {
to: string[],
subject: string,
html: string,
text: string,
text: string = convert(html),
): Promise<void> {
const info = await this.transporter.sendMail({
from, // sender address
Expand Down

0 comments on commit 2757dea

Please sign in to comment.