Setup and configure Apex mail

Make sure you have Apex setup to access your mailserver:

sqlplus / as sysdba
alter session set current_schema = apex_040200;
begin
  apex_instance_admin.set_parameter('SMTP_HOST_ADDRESS', 'smtpserver.domain.com');
  apex_instance_admin.set_parameter('SMTP_HOST_PORT', '25');
  commit;
end;
/

Setup ACL:

begin
  dbms_network_acl_admin.create_acl (
   acl         => 'mailserver.xml',
   description => 'permissions to access outgoing mailserver',
   principal   => 'SCOTT',
   is_grant    => TRUE,
   privilege   => 'connect'
  );
  commit;

  dbms_network_acl_admin.assign_acl ('/sys/acls/mailserver.xml','smtpserver.domain.com',25);
  commit;

  dbms_network_acl_admin.add_privilege('/sys/acls/mailserver.xml','APEX_040200',TRUE,'connect');
  commit;  
end;
/

Send some testmail:

declare
    cursor c_ws is
      select workspace_id
      from   apex_workspaces
      where  workspace = 'YOUR_WORKSPACE';

  l_ws_id number;
  l_id    number;
begin
  open  c_ws;
  fetch c_ws into l_ws_id;
  close c_ws;
  apex_util.set_security_group_id(l_ws_id);
  --
  l_id := apex_mail.send(
        p_to        => 'to_address@somewhere.com',
        p_from      => 'from@elsewhere.nl',
        p_subj      => 'subject',
        p_body      => 'text',
        p_body_html => null);
  apex_mail.push_queue;
  commit;
end;
/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.