I'm having difficulty sending email notifications through DBMS_SCHEDULER.
I've gone through instructions here on adding email notifications and here on configuring the mail server but I still don't get any e-mails sent. I'm using the same mail server settings on UTL_MAIL (to send mail using procedures) and Oracle Enterprise Manager (To get backup and availability email and they work fine.) I would rather not use UTL_MAIL instead as it doesn't offer the simplicity and flexibility I'm hoping to achieve with scheduler emails.
Below we have what server settings I've configured and how I'm trying to create a job that will send notifications.
/*Settings*/
exec dbms_scheduler.set_scheduler_attribute('email_server','xxx');
exec dbms_scheduler.set_scheduler_attribute('email_sender','Scheduler#domain.com');
/* Dont think this is needed but added anyway, this allows UTL_MAIL to work*/
alter system set smtp_out_server = 'xxx';
begin
dbms_network_acl_admin.create_acl (
acl => 'dbms_scheduler.xml',
description => 'Allow mail to be send',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'connect'
);
commit;
end;
begin
dbms_network_acl_admin.add_privilege (
acl => 'dbms_scheduler.xml',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'resolve'
);
commit;
end;
begin
dbms_network_acl_admin.assign_acl(
acl => 'dbms_scheduler.xml',
host => 'xxx'
);
commit;
end;
/*Create a quick, simple job*/
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"SCHEMA"."EMAIL_TEST"',
job_type => 'STORED_PROCEDURE',
job_action => 'SCHEMA.DO_MOD',
number_of_arguments => 0,
start_date => NULL,
repeat_interval => NULL,
end_date => NULL,
enabled => FALSE,
auto_drop => FALSE,
comments => '');
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'restartable', value => TRUE);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_RUNS);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'raise_events', value => '511');
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => '"SCHEMA"."EMAIL_TEST"',
recipients => 'user#xxx',
sender => 'oracle#xxx',
subject => 'Oracle Scheduler Job Notification - %job_owner%.%job_name%.%job_subname% %event_type%',
body => 'Job: %job_owner%.%job_name%.%job_subname%
Event: %event_type%
Date: %event_timestamp%
Log id: %log_id%
Job class: %job_class_name%
Run count: %run_count%
Failure count: %failure_count%
Retry count: %retry_count%
Error code: %error_code
%Error message: %error_message%',
events => 'job_started, job_broken, job_chain_stalled, job_completed, job_disabled, job_failed, job_over_max_dur, job_run_completed, job_sch_lim_reached, job_stopped, job_succeeded',
filter_condition => NULL
);
DBMS_SCHEDULER.enable(
name => '"SCHEMA"."EMAIL_TEST"');
END;
This code all completes successfully but I get no emails. I can also see the entries in user_scheduler_notifications but receive nothing.
Related
I have a problem with the oracle apex default PDF showing custom heading and company logo. as like below picture
enter link description here
EJ Egyed,
Here is my code below,
DECLARE
l_columns apex_data_export.t_columns;
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
l_print_config apex_data_export.t_print_config;
BEGIN
l_context := apex_exec.open_query_context(
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select * FROM emp order by deptno' );
-- Define columns
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'DEPTNO',
p_heading => 'Dept No');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'EMPNO',
p_heading => 'Emp No');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'ENAME',
p_heading => 'Emp Name');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'SAL',
p_heading => 'Salary',
p_format_mask => 'FML999G999G999G999G990D00');
l_print_config := apex_data_export.get_print_config(
p_orientation => apex_data_export.c_orientation_portrait,
p_border_width => 1,
p_body_font_color => 'Black',
p_page_header => 'Dekko Legacy Group',
p_page_header_font_color => 'Black',
p_page_header_font_size => 20,
p_page_header_font_family => null,
p_page_header_font_weight => apex_data_export.c_font_weight_bold,
p_page_header_alignment => 'CENTER',
p_page_footer => 'Generated by '|| :APP_USER,
p_page_footer_font_color => 'Black',
p_page_footer_font_size => 10,
p_page_footer_font_family => null,
p_page_footer_font_weight => apex_data_export.c_font_weight_bold,
p_page_footer_alignment => 'LEFT',
p_border_color => 'Black');
l_export := apex_data_export.export (
p_context => l_context,
p_format => :P32_FORMAT,--apex_data_export.c_format_pdf,
p_columns => l_columns,
p_file_name => 'employees',
p_print_config => l_print_config
);
apex_exec.close( l_context );
apex_data_export.download(p_export => l_export);
EXCEPTION
WHEN others THEN
apex_exec.close( l_context );
raise;
END;
It's hard to add a logo and custom header to the default PDF export of Oracle APEX.
This is why we created APEX Office Print, which allows you to export based on a template you create. In your case, it's as easy as adding the logo and header in your Excel template and using a tag where you want the data to be. You find examples in the AOP Sample Apps.
There's a free tier of AOP and also paid options. Although it might be payable, you will save enormous time on creating the PDFs and reports you need and you have a much bigger toolset and options to give your end-users.
Hope that helps.
I'm trying to send e-Mail as a simple Send e-Mail process with Oracle APEX 11.2, and I can't figure out how the correct ACL has to be set. I tried this, but no success, still getting: ORA-24247: network access denied by access control list (ACL). What am I doing wrong?
SELECT * FROM dba_network_acl_privileges shows that all rules are granted and also select * from dba_network_acls shows both rules.
Thanks in Advance!
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'send_mail.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('send_mail.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => '*',lower_port => null, upper_port => null);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => 'smtp.google.com',lower_port => null, upper_port => null);
commit;
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'utl_smtp.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('utl_smtp.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'utl_smtp.xml',host => '*',lower_port => null, upper_port => null);
END;
This is how I do it.
-- Drop ACL ====================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.drop_acl (acl => 'mydba.xml');
END;
/
-- Create ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'mydba.xml',
description => 'SMTP, MAIL, HTTP Access',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
END;
/
-- Assign ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (acl => 'mydba.xml',
HOST => '*',
lower_port => NULL,
upper_port => NULL);
END;
/
-- Add privilege ===============================================================
BEGIN
-- LITTLEFOOT
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'resolve',
start_date => NULL,
end_date => NULL);
END;
/
COMMIT;
When new users require privileges, I just copy/paste LITTLEFOOT's data from the "Add privilege" procedure and change principal's name (currently, there are dozen of users in my script).
I'm running Oracle 18c XE
I'm trying to connect to the following URL :
URL := 'https://domain.example.com/api'
apex_web_service.make_rest_request(p_url => URL, p_http_method => GetOrPost, p_body => RequestBody);
I'm getting the error :
ORA-29273: HTTP request failed
ORA-06512: at "APEX_190200.WWV_FLOW_WEB_SERVICES", line 1283
ORA-06512: at "APEX_190200.WWV_FLOW_WEB_SERVICES", line 924
ORA-24247: network access denied by access control list (ACL)
I tried to create an ACL for that
exec DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'MyACL.xml', description => 'MyACL', principal => 'Schema', is_grant => true, privilege => 'connect');
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'MyACL.xml', principal => 'Schema', is_grant => true, privilege => 'resolve');
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => '*', lower_port => 443, upper_port => 443);
tried several assigns :
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => 'domain.example.com/api', lower_port => 443, upper_port => 443);
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => 'domain.example.com/api');
None is working.
Can someone help please ?
Thanks.
Cheers
I am trying to send mail with apex_mail
Here is my configuration , but i did receive any mails
Is there something missing?
Thanks
Execute this code as sysdba to grant permissions for your DB User to connect to smtp server:
begin
dbms_network_acl_admin.create_acl
(
acl => 'mail.xml',
description => 'Access to smtp server',
principal => 'DBUser', -- DB Schema (grantee)
is_grant => true,
privilege => 'connect',
start_date => null,
end_date => null
);
dbms_network_acl_admin.assign_acl(
acl => 'mail.xml',
host => 'mail.muncipaldata.com', -- SMTP host
lower_port => 1025,
upper_port => 1025
);
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
acl => 'mail.xml',
principal => 'DBUser', -- DB Schema (grantee)
is_grant => true,
privilege => 'resolve',
start_date => null,
end_date => null
);
end;
I've seen a couple of posts here on this topic, but I can't manage to authenticate by users in a group. If I point the path to where a user is, authentication is successful. It's like it "cannot read" inside the group. I'm must be missing something.
my configs are:
$GLOBALS['ldapdsn'] = array(
// primary server MS AD Server
// port 636 is ldaps and port 389 is ldap
array(
'url' => '172.25.20.3',
'port' => '389',
'version' => '3',
'referral' => 'false',
'basedn' => 'CN=RedcapUsers,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'binddn' => 'CN=RedcapLdap,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'bindpw' => 'mypass',
'attributes' => array('sAMAccountName'),
'userattr' => 'sAMAccountName',
'userfilter' => '(objectClass=user)',
), //
RedcapUsers is the AD group.
Binding works fine.
I'm pretty new in code writing.
Filter the AD group ( See last line of code) and issue is resolved !
'url' => 'Active Directory ip',
'port' => '636',
'version' => '3',
'referral' => 'false',
'basedn' => 'OU=Users,DC=Ali,DC=local', // Must be exact OU where users are
'binddn' => 'CN=service_redcap,OU=Users,DC=Ali,DC=local', //-- User who give access to AD
'bindpw' => 'myPassword', // ---Password to above user
'attributes' => array('samAccountName'),
'userattr' => 'samAccountName',
'userfilter' => '(memberOf=CN=REDCAP_GROUP,DC=Ali,DC=local)' //-- Users in this group will loging to Redcap