Oracle version:
SQL*Plus: Release 12.1.0.2.0 Production on Tue Feb 26 15:14:07 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Tue Feb 26 2019 14:05:04 -06:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL>
I am currently working on writing a stored procedure to send out emails from our new Oracle 12c SuperCluster Database to our SMTP exchange server:
PL/SQL Code:
create or replace PROCEDURE mail_sc (sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2) IS
conn utl_smtp.connection;
BEGIN
conn := UTL_SMTP.OPEN_CONNECTION('Exchange server hostname');
UTL_SMTP.HELO(conn, 'exchange server hostname');
UTL_SMTP.MAIL(conn, 'sender_email');
UTL_SMTP.RCPT(conn, 'recipient_email');
UTL_SMTP.OPEN_DATA(conn);
UTL_SMTP.WRITE_DATA(conn, UTL_TCP.CRLF || 'Hello, world!');
UTL_SMTP.CLOSE_DATA(conn);
UTL_SMTP.QUIT(conn);
END;
execute MAIL_SC('sender_email','recipient_email','test test','Test Message');
After executing store procedure I ended up receiving errors like:
Error report -
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_TCP", line 19
ORA-06512: at "SYS.UTL_TCP", line 280
ORA-06512: at "SYS.UTL_SMTP", line 163
ORA-06512: at "SYS.UTL_SMTP", line 199
ORA-06512: at "User_name.MAIL_SC", line 7
ORA-06512: at line 1
24247. 00000 - "network access denied by access control list (ACL)"
*Cause: No access control list (ACL) has been assigned to the target
host or the privilege necessary to access the target host has not
been granted to the user in the access control list.
*Action: Ensure that an access control list (ACL) has been assigned to
the target host and the privilege necessary to access the target
host has been granted to the user.
Is there a simple way to write PL/SQL Code that communicates with SMTP server via stored procedures that sends email to recipients after successfully completion of stored procedure run.
I am a newbie to 12c environment and setting up the SMTP server on our new 12c
Any help is truly appreciated.
Jay