APEX_MAIL.SEND 函数不工作,虽然它没有给出任何错误
APEX_MAIL.SEND function not working though its not giving any error
必须使用 APEX_MAIL.SEND()
方法从 oracle apex
发送电子邮件。
我正在使用代码:
BEGIN
apex_mail.send(p_to => 'tanmoydawn@gmail.com'/*l_to_addr*/,
p_from => 'tanmoydawn@gmail.com'/*l_from_addr*/,
p_bcc => l_bcc_addr,
p_subj => l_mail_sub,
p_body => 'Service Request ' || :mail_body ||
'Note:- This is a system generated Email. Please DO NOT REPLY to it.');
apex_mail.push_queue;
EXCEPTION
when others then
INSERT INTO send_mail_error_test VALUES ('Send_mail',systimestamp,:service_request_id||'-err:'||seq_service_req_error_id.NEXTVAL);
COMMIT;
END;
*** 所有变量都包含正确的值
正在使用数据库并且该数据库具有 ACL(访问控制列表)访问权限
在 apex 管理服务中,将电子邮件的实例设置配置为主机名、端口、电子邮件配置已启用。
UTL_SMTP 包已安装
在同一进程中,在控制流的同一点,使用 utl_Smtp 发送邮件的代码工作正常,尽管 apex_mail.send() 不工作。
apex_mail.send()
没有给出任何错误或异常,但我没有收到来自它的电子邮件。
有一个困惑,得到了一些类似的解决方案,'APEX_040200
'应该被添加到ACL
。但是我正在使用并在其上实现代码的数据库,比如'apex_user
'已经添加到ACL
。即使现在我还必须在 ACL
中添加“APEX_040200
”或“APEX_050200
”吗?
任何人都可以帮助我并给我一个富有成效的解决方案吗?我正在使用顶点 5.0.2.00.07。
我猜你应该按照他们说的去做 here,但是使用正确的 APEX 版本,就像你猜的那样......尝试各种,使用 APEX_050000
(而不是 APEX_050200
将暗示 APEX 5.2 - 尚未发布):
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;
可以在 the apex_mail api documentation 中找到:
Before you can send email from an Application Builder application, you
must:
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.
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.
您指定的实例设置没问题。你的 "database has ALC access" 没有任何意义。你是说你有一个使用网络 ACL 的数据库吗? (11 克或更高)
该文档链接到 "the Enabling Network Services in Oracle Database 11g or Later" documentation
这份文件不会让你猜到:
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:...
如果您使用的是旧版本的 apex,例如 4.2,则授予的用户是另一个用户,可以在文档中找到。或者,您可以找出
例如查询 ALL_USERS
视图并找到 APEX_######
用户,选择版本号最高的用户:
select *
from all_users
where username like 'APEX%'
order by username;
在我们的例子中,这是一份工作,ORACLE_APEX_MAIL_QUEUE,状态为 'RUNNING' 8 天。显然,它对队列或邮件进程持有某种锁定
我们扼杀了这份工作,仅此而已。
(有关职位和状态,请参阅 dba_scheduler_jobs)
我遇到了同样的问题。可以使用 utl_smtp 发送电子邮件,但不能使用 apex_mail.send。结果我在 smtp 服务器 url.
中多了一个 space
APEX 的电子邮件服务器已在 APEX 实例工作中设置space。检查“管理实例” > 'Instance Settings' > 'Email' > 'SMTP Host Address'
也尝试检查实例工作'Monitor Activity'中的日志space。
必须使用 APEX_MAIL.SEND()
方法从 oracle apex
发送电子邮件。
我正在使用代码:
BEGIN
apex_mail.send(p_to => 'tanmoydawn@gmail.com'/*l_to_addr*/,
p_from => 'tanmoydawn@gmail.com'/*l_from_addr*/,
p_bcc => l_bcc_addr,
p_subj => l_mail_sub,
p_body => 'Service Request ' || :mail_body ||
'Note:- This is a system generated Email. Please DO NOT REPLY to it.');
apex_mail.push_queue;
EXCEPTION
when others then
INSERT INTO send_mail_error_test VALUES ('Send_mail',systimestamp,:service_request_id||'-err:'||seq_service_req_error_id.NEXTVAL);
COMMIT;
END;
*** 所有变量都包含正确的值
正在使用数据库并且该数据库具有 ACL(访问控制列表)访问权限
在 apex 管理服务中,将电子邮件的实例设置配置为主机名、端口、电子邮件配置已启用。
UTL_SMTP 包已安装
在同一进程中,在控制流的同一点,使用 utl_Smtp 发送邮件的代码工作正常,尽管 apex_mail.send() 不工作。
apex_mail.send()
没有给出任何错误或异常,但我没有收到来自它的电子邮件。有一个困惑,得到了一些类似的解决方案,'
APEX_040200
'应该被添加到ACL
。但是我正在使用并在其上实现代码的数据库,比如'apex_user
'已经添加到ACL
。即使现在我还必须在ACL
中添加“APEX_040200
”或“APEX_050200
”吗?
任何人都可以帮助我并给我一个富有成效的解决方案吗?我正在使用顶点 5.0.2.00.07。
我猜你应该按照他们说的去做 here,但是使用正确的 APEX 版本,就像你猜的那样......尝试各种,使用 APEX_050000
(而不是 APEX_050200
将暗示 APEX 5.2 - 尚未发布):
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;
可以在 the apex_mail api documentation 中找到:
Before you can send email from an Application Builder application, you must:
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.
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.
您指定的实例设置没问题。你的 "database has ALC access" 没有任何意义。你是说你有一个使用网络 ACL 的数据库吗? (11 克或更高) 该文档链接到 "the Enabling Network Services in Oracle Database 11g or Later" documentation
这份文件不会让你猜到:
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:...
如果您使用的是旧版本的 apex,例如 4.2,则授予的用户是另一个用户,可以在文档中找到。或者,您可以找出
例如查询 ALL_USERS
视图并找到 APEX_######
用户,选择版本号最高的用户:
select *
from all_users
where username like 'APEX%'
order by username;
在我们的例子中,这是一份工作,ORACLE_APEX_MAIL_QUEUE,状态为 'RUNNING' 8 天。显然,它对队列或邮件进程持有某种锁定
我们扼杀了这份工作,仅此而已。
(有关职位和状态,请参阅 dba_scheduler_jobs)
我遇到了同样的问题。可以使用 utl_smtp 发送电子邮件,但不能使用 apex_mail.send。结果我在 smtp 服务器 url.
中多了一个 spaceAPEX 的电子邮件服务器已在 APEX 实例工作中设置space。检查“管理实例” > 'Instance Settings' > 'Email' > 'SMTP Host Address'
也尝试检查实例工作'Monitor Activity'中的日志space。