Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 📧 Email Bounce Alert Script
// --------------------------------------------------------------
// Purpose:
// This mail script detects bounced-back emails in the Junk module
// and identifies recipient addresses from the email body.
//
// When a bounce is detected, it automatically triggers a notification
// containing the affected email IDs and a link to the email record.
//
// Type: Email Script
// Trigger: Notification

(function runMailScript(current, template, email, email_action, event) {

// --- Step 1: Function to extract email addresses from email body ---
function extractEmails(html) {
// Regular expression to match email patterns
var emailPattern = /[\w\-]+@[\w\-]+/g;

// Find all matching email addresses in the body
var emails = html.match(emailPattern);

// Return the array of emails or an empty array if none found
return emails || [];
}

// --- Step 2: Convert the email body into plain text ---
var body = current.body.toString().replaceAll('"', '');

// --- Step 3: Extract email addresses from the content ---
var extractedEmails = extractEmails(body);

// --- Step 4: Build the notification message ---
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
template.print("<br><strong>User(s) who missed the email:</strong> " + extractedEmails.join(', '));
template.print("<br><strong>Link to the bounced email record:</strong> ");
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + 'sys_email.do?sys_id=' + current.sys_id + '">Click here</a>');

})(current, template, email, email_action, event);
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
📧 Email Bounce Alert System
📘 Overview

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.

🧩 Problem Statement

In large organizations, emails sometimes bounce back because of mail server issues, blacklisted IPs, or invalid addresses.
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.

💡 Solution

This email script automates the detection and notification process.

The email script is called from a Notification configured on the sys_email table.

Email Script:

Extracts affected recipient email addresses from the email body using RegEx pattern matching.

Generates an automatic notification alert listing all affected users.

Provides a direct link to the bounced email record for quick investigation.

Notification settings:

When to send: Record inserted or updated

Inserted checkbox: Marked

Condition: Mailbox is Junk AND Body is not empty

Proper recipient(s) and subject line set in the notification.


🚀 Benefits

⚡ Immediate visibility of bounced or undelivered emails.

🧠 Automated extraction of recipient information — no manual tracking required.

📩 Faster communication recovery, ensuring critical business messages reach the intended audience.

🔗 Direct record access for faster troubleshooting and action.
Loading