APEX_MAIL.SEND function not working though its not giving any error

感情迁移 提交于 2019-12-04 10:58:55

As can be found in the apex_mail api documentation:

Before you can send email from an Application Builder application, you must:

  1. Log in to Oracle Application Express Administration Services and configure the email settings on the Instance Settings page. See "Configuring Email" in Oracle Application Express Administration Guide.

  2. If you are running Oracle Application Express with Oracle Database 11g release 1 (11.1), you must enable outbound mail. In Oracle Database 11g release 1 (11.1), the ability to interact with network services is disabled by default. See "Enabling Network Services in Oracle Database 11g" in Oracle Application Express Application Builder User's Guide.

You specified instance settings are ok. Your "database has ALC access" doesn't mean anything. Do you mean you have a database which uses network ACLs? (11g or higher) That same documentation links to "the Enabling Network Services in Oracle Database 11g or Later" documentation

This document does not leave you guessing:

By default, the ability to interact with network services is disabled in Oracle Database 11g Release 1 or 2 or later. Therefore, if you are running Oracle Application Express with Oracle Database 11g Release 1 or 2 or later, you must use the new DBMS_NETWORK_ACL_ADMIN package to grant connect privileges to any host for the APEX_050000 database user. Failing to grant these privileges results in issues with:...

If you have an older version of apex, eg 4.2, the user to grant to is another one, and can be found in the documentation. Alternatively, you can just find out by for example querying the ALL_USERS view and find the APEX_###### users, pick the one with the highest version number:

select *
from all_users
where username like 'APEX%'
order by username;

in our case, it was a job, ORACLE_APEX_MAIL_QUEUE, which had status 'RUNNING' for 8 days. Apparently, it held some kind of lock on the queue or mailprocess

We killed the job and that was it.

(see dba_scheduler_jobs for the job & status)

I guess you should do as they say here, but with the proper APEX version, as you guessed... try various, with APEX_050000 (rather than APEX_050200 that would imply APEX 5.2 - not released yet):

DECLARE
  ACL_PATH VARCHAR2(4000);
BEGIN
    -- Look for the ACL currently assigned to '*' and give APEX_050000
    -- the "connect" privilege if APEX_050000
    -- does not have the privilege yet.
  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
    WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
  IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE (ACL_PATH,'APEX_050000','connect') IS NULL THEN
    DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,'APEX_050000', TRUE, 'connect');
  END IF;
  EXCEPTION
    -- When no ACL has been assigned to '*'.
  WHEN NO_DATA_FOUND THEN
    DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
    'ACL that lets power users to connect to everywhere',
    'APEX_050000', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;
Rob B

I had this same problem. Could send email using utl_smtp, but could not with apex_mail.send. Turned out I had an extra space in the smtp server url.

Email server for APEX is setup in the APEX Instance workspace. Check "Manage Instance' > 'Instance Settings' > 'Email' > 'SMTP Host Address'

Also try checking the Logs in 'Monitor Activity' in the Instance Workspace.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!