-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
171 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import nodeMailer from "nodemailer"; | ||
import { prisma } from "../../../prisma"; | ||
|
||
export async function sendComment(ticket: any) { | ||
export async function sendComment( | ||
comment: string, | ||
title: string, | ||
email: string | ||
) { | ||
try { | ||
let mail; | ||
|
||
const emails = await prisma.email.findMany(); | ||
|
||
if (emails.length > 0) { | ||
if (emails.length === 0) { | ||
if (process.env.ENVIRONMENT === "development") { | ||
let testAccount = await nodeMailer.createTestAccount(); | ||
mail = nodeMailer.createTransport({ | ||
|
@@ -32,52 +36,52 @@ export async function sendComment(ticket: any) { | |
}); | ||
} | ||
|
||
console.log("Sending email to: ", ticket.email); | ||
console.log("Sending email to: ", email); | ||
|
||
let info = await mail.sendMail({ | ||
from: '"No reply 👻" [email protected]', // sender address | ||
to: ticket.email, | ||
to: email, | ||
subject: `New comment on a ticket`, // Subject line | ||
text: `Hello there, Ticket ${ticket.id}, which you reported on ${ticket.createdAt}, has now been created and logged`, // plain text body | ||
text: `Hello there, Ticket ${title}, has had an update with a comment of ${comment}`, // plain text body | ||
html: ` | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html lang="en"> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" /> | ||
</head> | ||
<div id="" style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0">Ticket Created<div></div> | ||
</div> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" /> | ||
</head> | ||
<div id="" style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0">Ticket Created<div></div> | ||
</div> | ||
<body style="background-color:#ffffff;margin:0 auto;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"> | ||
<table align="center" role="presentation" cellSpacing="0" cellPadding="0" border="0" width="100%" style="max-width:600px;margin:0 auto"> | ||
<tr style="width:100%"> | ||
<td> | ||
<table style="margin-top:8px" align="center" border="0" cellPadding="0" cellSpacing="0" role="presentation" width="100%"> | ||
</table> | ||
<h1 style="color:#1d1c1d;font-size:16px;font-weight:700;margin:10px 0;padding:0;line-height:42px">Ticket Created: ${ticket.id}</h1> | ||
<p style="font-size:20px;line-height:28px;margin:4px 0"> | ||
<p>Hello, <br>Your ticket has now been created and logged.</p> | ||
<p style="font-size:14px;margin:16px 0;color:#000"> | ||
Kind regards, | ||
<table align="center" border="0" cellPadding="0" cellSpacing="0" role="presentation" width="100%"> | ||
<tbody> | ||
<tr> | ||
<body style="background-color:#ffffff;margin:0 auto;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"> | ||
<table align="center" role="presentation" cellSpacing="0" cellPadding="0" border="0" width="100%" style="max-width:600px;margin:0 auto"> | ||
<tr style="width:100%"> | ||
<td> | ||
<a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slackhq.com" rel="noopener noreferrer">Our blog</a> | <a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slack.com/legal" rel="noopener noreferrer">Documentation</a> | <a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slack.com/help" rel="noopener noreferrer">Discord</a> </a> | ||
<p style="font-size:12px;line-height:15px;margin:16px 0;color:#b7b7b7;text-align:left">This was an automated message sent by peppermint.sh -> An open source helpdesk solution</p> | ||
<p style="font-size:12px;line-height:15px;margin:16px 0;color:#b7b7b7;text-align:left;margin-bottom:50px">©2022 Peppermint Ticket Management, a Peppermint Labs product.<br />All rights reserved.</p> | ||
<table style="margin-top:8px" align="center" border="0" cellPadding="0" cellSpacing="0" role="presentation" width="100%"> | ||
</table> | ||
<h1 style="color:#1d1c1d;font-size:16px;font-weight:700;margin:10px 0;padding:0;line-height:42px">Ticket Update:</h1> | ||
<p style="font-size:20px;line-height:28px;margin:4px 0"> | ||
<p>${comment}</p> | ||
<p style="font-size:14px;margin:16px 0;color:#000"> | ||
Kind regards, | ||
<table align="center" border="0" cellPadding="0" cellSpacing="0" role="presentation" width="100%"> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slackhq.com" rel="noopener noreferrer">Our blog</a> | <a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slack.com/legal" rel="noopener noreferrer">Documentation</a> | <a target="_blank" style="color:#b7b7b7;text-decoration:underline" href="https://slack.com/help" rel="noopener noreferrer">Discord</a> </a> | ||
<p style="font-size:12px;line-height:15px;margin:16px 0;color:#b7b7b7;text-align:left">This was an automated message sent by peppermint.sh -> An open source helpdesk solution</p> | ||
<p style="font-size:12px;line-height:15px;margin:16px 0;color:#b7b7b7;text-align:left;margin-bottom:50px">©2022 Peppermint Ticket Management, a Peppermint Labs product.<br />All rights reserved.</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</table> | ||
</body> | ||
</html> | ||
</html> | ||
`, | ||
}); | ||
|
||
|
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
Oops, something went wrong.