Skip to content

Commit 7758d08

Browse files
authored
Iamshankha/email bounce alert system (#1953)
1 parent fed228f commit 7758d08

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// 📧 Email Bounce Alert Script
2+
// --------------------------------------------------------------
3+
// Purpose:
4+
// This mail script detects bounced-back emails in the Junk module
5+
// and identifies recipient addresses from the email body.
6+
//
7+
// When a bounce is detected, it automatically triggers a notification
8+
// containing the affected email IDs and a link to the email record.
9+
//
10+
// Type: Email Script
11+
// Trigger: Notification
12+
13+
(function runMailScript(current, template, email, email_action, event) {
14+
15+
// --- Step 1: Function to extract email addresses from email body ---
16+
function extractEmails(html) {
17+
// Regular expression to match email patterns
18+
var emailPattern = /[\w\-]+@[\w\-]+/g;
19+
20+
// Find all matching email addresses in the body
21+
var emails = html.match(emailPattern);
22+
23+
// Return the array of emails or an empty array if none found
24+
return emails || [];
25+
}
26+
27+
// --- Step 2: Convert the email body into plain text ---
28+
var body = current.body.toString().replaceAll('"', '');
29+
30+
// --- Step 3: Extract email addresses from the content ---
31+
var extractedEmails = extractEmails(body);
32+
33+
// --- Step 4: Build the notification message ---
34+
template.print("This alert has been generated because a bounced email incident may have occurred due to possible IP blacklisting."); //example: IP blacklisting use case
35+
template.print("<br><strong>User(s) who missed the email:</strong> " + extractedEmails.join(', '));
36+
template.print("<br><strong>Link to the bounced email record:</strong> ");
37+
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + 'sys_email.do?sys_id=' + current.sys_id + '">Click here</a>');
38+
39+
})(current, template, email, email_action, event);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
📧 Email Bounce Alert System
2+
📘 Overview
3+
4+
The Email Bounce Alert System automatically detects bounced-back emails in the Junk Mail module and alerts administrators or support teams about affected recipients. It helps identify communication failures quickly and ensures that important client messages aren’t missed due to IP blacklisting or delivery issues.
5+
6+
🧩 Problem Statement
7+
8+
In large organizations, emails sometimes bounce back because of mail server issues, blacklisted IPs, or invalid addresses.
9+
Currently, identifying which users didn’t receive an important message requires manual checking of the Junk Email module, leading to delays in response and potential loss of critical communication.
10+
11+
💡 Solution
12+
13+
This email script automates the detection and notification process.
14+
15+
The email script is called from a Notification configured on the sys_email table.
16+
17+
Email Script:
18+
19+
Extracts affected recipient email addresses from the email body using RegEx pattern matching.
20+
21+
Generates an automatic notification alert listing all affected users.
22+
23+
Provides a direct link to the bounced email record for quick investigation.
24+
25+
Notification settings:
26+
27+
When to send: Record inserted or updated
28+
29+
Inserted checkbox: Marked
30+
31+
Condition: Mailbox is Junk AND Body is not empty
32+
33+
Proper recipient(s) and subject line set in the notification.
34+
35+
36+
🚀 Benefits
37+
38+
⚡ Immediate visibility of bounced or undelivered emails.
39+
40+
🧠 Automated extraction of recipient information — no manual tracking required.
41+
42+
📩 Faster communication recovery, ensuring critical business messages reach the intended audience.
43+
44+
🔗 Direct record access for faster troubleshooting and action.

0 commit comments

Comments
 (0)