Allard Hillebrand
Allard Hillebrand

Reputation: 1

Retrieve the APEX Instance admin SMTP_FROM to use in APEX_MAIL.send

I would like to send emails from APEX or PL/SQL. This works if the FROM parameter is the same as our Instance Administrator has configured in SMTP. I have the email adress, but I would like to retrieve it from the Instance Parameter directly, so if the SMTP FROM changes, all code will still work.

I can retrieve it by using the APEX_INSTANCE_ADMIN.GET_PARAMETER( 'SMTP_FROM' ), but that only works if I am logged in as Instance Admin. But how do I make this function accessible to our Developer Users? So they can use that function in their APEX_MAIL code, so if the email changes on instance level, everything works fine.

I can also make an Application Setting with the FROM, and use that, but I would automate that step.

The Oracle version is 19C, and APEX version 24.1

Can you help me with this?

I tried to make a wrapper if I am logged in as Instance Admin, but I got a privilege error. After making the spec, the body looks like this:

CREATE OR REPLACE PACKAGE body crs_utils  
  AS 
  FUNCTION get_smtp_from_address RETURN VARCHAR2 
  IS
  BEGIN
    RETURN APEX_INSTANCE_ADMIN.GET_PARAMETER( 'SMTP_FROM' );
  END get_smtp_from_address;
END crs_utils;
/

The error is: "insufficient privilege to access object PUBLIC.APEX_INSTANCE_ADMIN"

Upvotes: 0

Views: 43

Answers (0)

Related Questions