Monday, 18 July 2016

SMTP Preferences in the database

At the end of the month, the server administrators are changing the IP address of our smtp server.
I was given a list of all servers registered in the server log over the last few weeks.
On these servers are EDI apps, task scheduler jobs, databases and application servers and it was my task to drill through each and everyone, finding all the instances of where the smtp server was utilized directly through IP. Most of the stuff was simple, but I did struggle initially to find the smtp preferences for APEX installations, scheduler job notifications and plain old job notifications.

There locations can be found using the following queries and blocks of pl/sql.

To find the SMTP relay for an APEX schema:
SELECT
APEX_040200.WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_HOST_ADDRESS'),
APEX_040200.WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_HOST_PORT'),
APEX_040200.WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_USERNAME'),
APEX_040200.WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_PASSWORD'),
APEX_040200.WWV_FLOW_PLATFORM.GET_PREFERENCE('SMTP_TLS_MODE')
FROM dual

To change the SMTP relay for APEX:
EXEC APEX_UTIL.SET_PREFERENCE(p_preference=>'SMTP_HOST_ADDRESS', p_value =>'smtprelay.<smtpserver>.net');

To see the settings of the SMTP relay for the scheduler jobs:
SET SERVEROUTPUT ON

DECLARE
  V_VALUE VARCHAR(100);
BEGIN
  DBMS_SCHEDULER.GET_SCHEDULER_ATTRIBUTE('email_server',V_VALUE);
  DBMS_OUTPUT.PUT_LINE(V_VALUE);
END;
/

To see the settings for the old dba jobs system:
SELECT attribute_name, 
       value 
  FROM dba_scheduler_global_attribute 
 WHERE attribute_name like '%EMAIL%';

ATTRIBUTE_NAME                 VALUE
------------------------------ -------------------------------------
EMAIL_SERVER                   smtprelay.<smtpserver>.net:25
EMAIL_SERVER_ENCRYPTION        NONE
EMAIL_SERVER_CREDENTIAL
EMAIL_SENDER

No comments:

Post a Comment