Skip to Main Content
Feature Request FR-3112
Product Area APIs
Status CLOSED

18 Voters

Pre Hook Function in Apex Mail Service

shibi.ns Internal
· Apr 30 2023

Idea Summary

An enhancement for in  APEX that could be useful is the implementation of a Pre Hook Function for Apex_MAIL, the built-in email service in APEX.

The Pre Hook Function would allow developers/instance admin to execute custom code before sending an email through Apex_MAIL or other emails . This would be useful in scenarios where certain email content or recipients need to be modified or validated before sending.

To implement this enhancement,  APEX would need to add a new  API to register a Pre Hook Function at instance , workspace or application level. The function would receive the email content and recipients as input parameters, allowing the developer to modify them as needed. 

For example, a Pre Hook Function could be used to check if a recipient is a valid email address, or to add dynamic content to the email body based on user input. This would provide greater flexibility and customization options for developers using Apex_MAIL in their applications.

Also It would be nice to have post hook function  

Use Case
What are the use cases in which this idea useful?

  • Add header in in Non Production environments ("This mail is from Test System")
  • Filter out mail non trusted domain  , Eg  Inside oracle  the mail should be send out to only @oracle.com com 
  • Limit mails send to users, for example  if we copy the application from production to non production  , only subscribed users on that users should receive the mai 
  • Scan email

Preferred Solution (Optional)

We reviewed this idea carefully, and while it was interesting, we concluded that due to all the internal implications we need to take into account, it is unlikely to make its way into APEX.

Known Duplicates

Known duplicates

FR-4297
FR-4297 Pre Hook Function for Apex_MAIL

Comments

Comments

  • dirk_strack OP 2 years ago

    In my opinion, scanning and filtering emails without user consent is highly problematic. It infringes upon individuals' privacy rights and violates the principle of consent, which is fundamental to ethical data handling. Spying on users through email scanning not only undermines trust but may also have legal implications, as it may contravene privacy laws in many jurisdictions.

    Emails are a form of private communication, and intercepting or filtering them without explicit user consent can be seen as an invasion of privacy. Users have the right to expect that their communications remain confidential unless they provide clear consent or when there are legitimate legal grounds for interception.

    It is important for companies and platforms to prioritize user privacy and ensure compliance with applicable laws and regulations. Implementing features that respect user consent, transparency, and control over their email communications is a more ethical approach.

    By fostering trust, protecting privacy, and adhering to legal requirements, companies can create a positive and secure user experience while respecting individual rights and expectations of privacy.

  • shibi.ns OP 2 years ago

    @dirk_strack 

    We are not taking about email send by the user , these are emails auto generated from system . Like when you create Order and Order Information is emailed to mail provided during placement of Order