diff options
| author | Leo Goetz <dev@leogtz.de> | 2026-05-08 15:48:37 +0200 |
|---|---|---|
| committer | Leo Goetz <dev@leogtz.de> | 2026-05-08 15:48:37 +0200 |
| commit | c3cb0ca317a52a740bf9625ca9df43f5c2306548 (patch) | |
| tree | aa8877dc2d651f16d23a629c4054043cae8be156 /src/actions/sendEmail.ts | |
inital commit
Diffstat (limited to 'src/actions/sendEmail.ts')
| -rw-r--r-- | src/actions/sendEmail.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/actions/sendEmail.ts b/src/actions/sendEmail.ts new file mode 100644 index 0000000..50394c5 --- /dev/null +++ b/src/actions/sendEmail.ts @@ -0,0 +1,27 @@ +import nodemailer from "nodemailer"; +import { emailConfig } from "../utils/email.js"; +import type { Project } from "../types.js"; + +const transporter = nodemailer.createTransport(emailConfig); + +export const sendAuditEmail = async (projects: Project[]) => { + const text = emailContent(projects); + const email = await transporter.sendMail({ + from: `"${emailConfig.senderName}" <${emailConfig.senderEmail}>`, + to: `${emailConfig.reciever}`, + subject: emailConfig.subject ?? "Dependency Audit!", + text: text, + }); + + return email; +}; + +const emailContent = (projects: Project[]): string => { + return `Here is your Report: +${projects.map((project) => { + let projectVulnerabilities = project.metadata.vulnerabilities.total; + return ` +${project.projectName} has ${projectVulnerabilities} Security Issues`; +})} +`; +}; |
