UTL_SMTP in 11g DB

hi,
I have a procedure for sending email from forms. The procedure is created in pl/sql.
It is working in 9i. but due to the new security in 11g the procedure in not working.
SEND_MAIL('sender email','recpientemail','header','message');
I am getting error ORA-24247.
I have checked in oracle site and found an article about this error code.
http://www.oracle.com/technology/pub/articles/oracle-database-11g-top-features/11g-security.html
i created the following :
begin
dbms_network_acl_admin.create_acl (
acl => 'utlpkg.xml',
description => 'Normal Access',
principal => 'CONNECT',
is_grant => TRUE,
privilege => 'connect',
start_date => null,
end_date => null
end;
Begin
dbms_network_acl_admin.add_privilege (
acl => 'utlpkg.xml',
principal => 'myuserid',
is_grant => TRUE,
privilege => 'connect',
start_date => null,
end_date => null);
End;
begin
dbms_network_acl_admin.assign_acl (
acl => 'utlpkg.xml',
host => 'mail.eim.ae',
lower_port => 22,
upper_port => 55);
end;
but still not working and where is in the above code saying about UTL_SMTP.

hi
Install UTL_MAIL:
# SQLPLUS SYS AS SYSDBA
SQL> @$ORACLE_HOME/rdbms/admin/utlmail.sql
SQL> @$ORACLE_HOME/rdbms/admin/prvtmail.plb
You define the SMTP_OUT_SERVER parameter in the init.ora rdbms initialization file. However, if SMTP_OUT_SERVER is not defined, this invokes a default of DB_DOMAIN which is guaranteed to be defined to perform appropriately.
Ensure that you are connected as SYS using the SYSDBA privilege, and then grant the following privileges to the Database Vault Owner account.
For example:
CONNECT SYS/AS SYSDBA
Enter password: password
GRANT CREATE PROCEDURE, DROP ANY PROCEDURE TO dbvowner;
GRANT EXECUTE ON UTL_TCP TO dbvowner;
GRANT EXECUTE ON UTL_SMTP TO dbvowner;
GRANT EXECUTE ON UTL_MAIL TO dbvowner;
GRANT EXECUTE ON DBMS_NETWORK_ACL_ADMIN TO dbvowner;
The UTL_TCP, UTL_SMTP, UTL_MAIL, and DBMS_NETWORK_ACL_ADMIN PL/SQL packages are used by the e-mail security alert that you will create.
Connect to SQL*Plus as the Oracle Database Owner (DV_OWNER) account.
For example:
CONNECT dbvowner
Enter password: password
Create the following procedure:
CREATE OR REPLACE PROCEDURE email_alert AS
msg varchar2(20000) := ‘Realm violation occurred for the ALTER TABLE Command Security Policy rule set. The time is: ‘;
BEGIN
msg := msg||to_char(SYSDATE, ‘Day DD MON, YYYY HH24:MI:SS’);
UTL_MAIL.SEND (
sender => ‘[email protected]’,
recipients => ‘[email protected]’,
subject => ‘Table modification attempted outside maintenance!’,
message => msg);
END email_alert;
Replace [email protected] with your e-mail address, and [email protected] with the e-mail address of the person you want to receive the notificationsarah

Similar Messages

  • Email sending is not working with utl_smtp (migrated from 9i to 11g)

    Hi,
    >
    We have used UTL_SMTP package to send emails in Oracle 9i. But when we have migrated to Oracle 11g, the procedure used to send emails compiled successfully, but we were not able to receive the mails.
    Not able to figure out the exact issue/error.
    Please let me know if there is any solution other than using UTL_MAIL in 11g.
    Thanks,
    Saranya

    Hi
    I faced similar issue that happened due to ACLs. Check metalink note 557070.1 for details.
    Hope it helps.
    Rgds
    Adnan

  • Need help in utl_smtp and utl_tcp in 11g and ACL files

    Hi,
    Recnetly we migrated from 10g to 11g. The thing is I couldnnt able to get access on utl_smtp and utl_tcp packages. And I am getting the following errors.
    ORA-24247: network access denied by access control list (ACL)
    ORA-06512: at "SYS.UTL_TCP", line 17
    ORA-06512: at "SYS.UTL_TCP", line 246
    ORA-06512: at "SYS.UTL_SMTP", line 115
    ORA-06512: at "SYS.UTL_SMTP", line 138
    ORA-06512: at "USWU48216.SEND_MAIL", line 19
    ORA-06512: at line 1
    After getting the above error I tried to configure ACL with below command, again its throwing error.
    exec dbms_network_acl_admin.add_privilege(acl => 'ACL_name.xml', principal => 'xxx', is_grant => TRUE, privilege => 'connect');
    ORA-31001: Invalid resource handle or path name "/sys/acls/ACL_name.xml"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 247
    ORA-06512: at line 1
    Any ideas, please..
    Edited by: user6476691 on Nov 9, 2008 12:03 AM

    Sathish,
    Thats a good webstie.
    I created an xml file. After that, when I was trying to
    begin
    dbms_network_acl_admin.add_privilege (
    acl => 'utlpkg.xml',
    principal      => 'xxx123',
    is_grant      => TRUE,
    privilege      => 'connect',
    start_date      => null,
    end_date      => null);
    end;
    I am getting tthe following error....
    ORA-31001: Invalid resource handle or path name "/sy
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 79
    ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 401
    ORA-06512: at line 2
    Any inputs ??? plz....
    Edited by: user6476691 on Nov 9, 2008 7:48 PM

  • 11g utl_smtp Security

    I have an application which supports 'phoning home' that, up until 11g was relatively easy to implement. Now I'm attempting to port it so that it will work with 11g but unfortunately, this doesn't seem to be all that easy.
    If I run this code as a scripted anonymous PL/SQL block it works:
    dbms_network_acl_admin.add_privilege (
    acl           => 'utlpkg.xml',
    principal      => 'USERNAME',
    is_grant      => TRUE,
    privilege      => 'connect',
    start_date      => null,
    end_date      => null);
    (Obviously, I've already created the acl in question). Unfortunately, if I attempt to run this from my administration application, or even try to put it in a stored procedure where I can just call it from my stored procedure, it does not work. I can't get it to compile in a stored procedure, and just running the SQL from my application raises no exceptions, but has no effect either. It appears that it must be commited in order for it to work, is this true? (In other words, unlike other Oracle security-related operations, this is not considered DDL?) Forcing a commit from my application has no effect, it still doesn't work.
    I'd like to incorporate this level of security into my application as opposed to having to run it externally from a script in order for it to function. Clearly I'm missing something here, but my results seem arbitrarily inconsistent. This may be in part because of the general suckiness of Vista on which I'm running 11g, or perhaps a problem with 11g itself, or, most likely, my own inability to code it correctly. I would appreciate any pointers to existing code that I might incorporate.
    Thanks!
    <RANT> I have NO IDEA why Oracle would chose to implement security based on xml when there is an existing structure that's been in the database for as long as I've work with it (grant priv to user). This seems to me to be an abuse of what xml should be used for, and I can only hope this over-exuberant use of xml can be rectified in a future release </RANT>

    Hi,
    You have to many explanation here www.ietf.org/rfc/rfc0821.txt
    and here
    www.ietf.org/rfc/rfc0822.txt
    Nicolas.

  • How to send email attachments in any format by utl_smtp?

    Hi,
    I am Using this Script for Sending Mail With an Attachment,i run this Script(Oracle 11g Database R1) and i got this Message "PL/SQL procedure successfully completed." but still i have not received the mail.
    Please advice me....
    set serveroutput on
    /* Formatted on 2010/06/03 21:26 (Formatter Plus v4.8.8) */
    DECLARE
    v_file_handle UTL_FILE.file_type;
    v_email_server VARCHAR2 (100) := 'Email_Server;
    v_conn UTL_SMTP.connection;
    v_port NUMBER := 25;
    v_reply UTL_SMTP.reply;
    v_msg VARCHAR2 (32767);
    v_line VARCHAR2 (1000);
    v_message VARCHAR2 (1000);
    b_connected BOOLEAN := FALSE;
    v_sender VARCHAR2 (50) := '************';
    v_strt_day varchar2(100);
    v_end_day varchar2(100);
    crlf VARCHAR2 (2) := CHR (13) || CHR (10);
    recpt VARCHAR2 (255) := '*********';
    slp PLS_INTEGER := 300;
    pdirpath VARCHAR2 (50) := 'D:\Mail_Process';
    pfilename VARCHAR2 (50) := 'Multifile.html';
    p_stat number     := 0;
    BEGIN
    /***** Check if the file exists ****/
    BEGIN
    v_file_handle := UTL_FILE.fopen (pdirpath, pfilename, 'R');
    EXCEPTION
    WHEN UTL_FILE.invalid_path
    THEN
    p_stat := 99;
    RETURN;
    WHEN OTHERS
    THEN
    p_stat := 99;
    RETURN;
    END;
    /***** Try to connect for three times, do sleep in between for 5minutes *****/
    FOR i IN 1 .. 3
    LOOP
    BEGIN
    --open the connection with the smtp server and do the handshake
    v_conn := UTL_SMTP.open_connection (v_email_server, v_port);
    v_reply := UTL_SMTP.helo (v_conn, v_email_server);
    IF 250 = v_reply.code
    THEN
    b_connected := TRUE;
    EXIT;
    END IF;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_LOCK.sleep (slp);
    END;
    END LOOP;
    IF b_connected = FALSE
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    v_reply := UTL_SMTP.mail (v_conn, v_sender);
    IF 250 != v_reply.code
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    v_reply := UTL_SMTP.rcpt (v_conn, recpt);
    IF 250 != v_reply.code
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    UTL_SMTP.open_data (v_conn);
    v_message :=
    'Sample Email This is an auto generated mail.
    Please do not reply to this mail.'
    || CHR (10);
    v_msg :=
    'Date: '
    || TO_CHAR (SYSDATE, 'Mon DD yy hh24:mi:ss')
    || crlf
    || 'From: '
    || v_sender
    || crlf
    || 'Subject: '
    || 'Sample file'
    || crlf
    || 'To: '
    || recpt
    || crlf
    || 'Mime-Version: 1.0'
    || crlf
    || 'Content-Type: multipart/mixed;
    boundary="DMW.Boundary.605592468"'
    || crlf
    || ''
    || crlf
    || v_message
    || crlf
    || ''
    || crlf
    || '--DMW.Boundary.605592468'
    || crlf
    || 'Content-Type: text/plain;
    name="v_message.txt"; charset=US-ASCII'
    || crlf
    || 'Content-Disposition: inline; filename="v_message.txt"'
    || crlf
    || 'Content-Transfer-Encoding: 7bit'
    || crlf
    || ''
    || crlf
    || v_message
    || crlf
    || crlf
    || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    /***** Prepare the attachment to be sent *****/
    v_msg :=
    crlf
    || '--DMW.Boundary.605592468'
    || crlf
    || 'Content-Type:
    application/octet-stream; name="'
    || pfilename
    || '"'
    || crlf
    || 'Content-Disposition: attachment; filename="'
    || pfilename
    || '"'
    || crlf
    || 'Content-Transfer-Encoding: 7bit'
    || crlf
    || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    LOOP
    BEGIN
    UTL_FILE.get_line (v_file_handle, v_line);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    EXIT;
    END;
    v_msg := '*** truncated ***' || crlf;
    v_msg := v_line || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    END LOOP;
    UTL_FILE.fclose (v_file_handle);
    v_msg := crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    v_msg := crlf || '--DMW.Boundary.605592468--' || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    UTL_SMTP.close_data (v_conn);
    UTL_SMTP.quit (v_conn);
    EXCEPTION
    WHEN OTHERS
    THEN
    p_stat := 99;
    END;
    Thank You
    Shan

    I would recommend not to use home grown email solutions and use what we all use
    1. UTL_MAIL oracle package http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10802/u_mail.htm
    or
    2. SMTP rock solid solution http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt

  • Error ORA-24247 after migrating from 10g to 11g

    Hi all,
    After a migration from a 10.2.0.3 (32bits) database to a 11.2.0.3 (64bits) database, we are facing a problem related to the UTL_SMTP package. I vale already created a ACL, as you can see below:
    -- create acl
    BEGIN
        DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (acl => 'user_processos.xml',
                                                                         description => 'abc',
                                                                    principal => 'PROCES',
                                                                    is_grant => TRUE,
                                                                    privilege => 'connect');
    END; 
    -- assign acl
    BEGIN
        DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'user_processos.xml'
                                                                    host => 'rac-abc',
                                                                 lower_port => 1521,
                                                                 upper_port => NULL);
              END;The problem is: After we try to execute a procedure that calls UTL_SMTP, with user PROCES the error ORA-24247 is raised. I did some research and they all point to the it is necessary to create an ACL to solve this probles, but the ACL already exists, as you can see above.

    Hi,
    I had the same issue, well multiple issues, with this at first. You should find the solution in one of these links. Make sure you have done each step in the lists and it will work.
    [url http://www.ora00600.com/scripts/databaseconfig/ORA-29278.html]ORA-29278 SMTP
    [url http://www.ora00600.com/scripts/11g/UTL_SMTP_ORA-06512.html]ORA-06512: at SYS.UTL_SMTP
    There are various parameters and configuration steps you need to make sure you have performed for it to work.
    Hopefully that helps,
    Rob
    Edited by: Rob_J on Feb 15, 2013 11:53 AM
    *link was not working                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to use alias in "From" field when I send a mail with utl_smtp ?

    Hi all,
    I'm using a PL/SQL package with an Oracle 11G database to send mails. It works fine but instead of use of my mail in "From" field like "[email protected]" as sender E-mail address, I would like to have "Toto" in the sender address. I tryied to use utl_smtp.mail(l_connection, '<toto> [email protected]') but it doesn't work. The only way I can send mail is when I set utl_smtp.mail(l_connection, '<[email protected]>') directly. When I use the Alias, I have an error from smtp server telling that I use a bad syntax address.
    Does someone know how to use the alias ? Where do I do a mistake ?
    Thank you for your help.
    sis2b

    Thank you, I find how to solve the problem thanks to your link.
    I try to send HTML E-mail so I had the From in the from field writen in the header of the mail and not to initialize the connection.
    sis2b.

  • Sending UTL_SMTP mail with Multiple attachment

    Hi,
    My Environment ----> Oracle Database 11g r1 on Windows 2003 Server (64Bit).
    The below script i used for sending mail with single attachment now i am trying to send mail with multiple attachment please tell me how to achieve this
    DECLARE
    /*LOB operation related varriables */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    RAISE;
    END;
    Thank you
    Shan

    Hi Saubhik
    Thanks for your reply, below script i used to send mail with multiple attachments, plsql code is executing without any error messages and i am also able to receive mail with the multiple attachment.
    i used your code which u posted in OTN then i changed little bit as per my need, output is ok.but the problem is if i want to add one more file then i have to add more varaiables in the code. i want to make the code which i can add more attachments without adding more varaiables i don't know the way to do this. can u please give me some hints.
    Thanks for your help
    Shan
    Script Used:
    DECLARE
    /*LOB operation related varriables01 */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*LOB operation related varriables02 */
    v_src_loc2 BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT1.LOG');
    l_buffer2 RAW(54);
    l_amount2 BINARY_INTEGER := 54;
    l_pos2 INTEGER := 1;
    l_blob2 BLOB := EMPTY_BLOB;
    l_blob_len2 INTEGER;
    v_amount2 INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment01. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*Preparing the LOB from file for attachment02. */
    DBMS_LOB.OPEN(v_src_loc2, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob2, TRUE); --Create temporary LOB to store the file.
    v_amount2 := DBMS_LOB.GETLENGTH(v_src_loc2); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob2, v_src_loc2, v_amount2); -- Loading from file into temporary LOB
    l_blob_len2 := DBMS_LOB.getlength(l_blob2);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment01
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment02
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export1.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos2 < l_blob_len2 LOOP
    DBMS_LOB.READ(l_blob2, l_amount2, l_pos2, l_buffer2);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer2));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer2 := NULL;
    l_pos2 := l_pos2 + l_amount2;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    RAISE;
    END;
    PL/SQL procedure successfully completed.
    Edited by: SHAN2009 on May 11, 2011 1:05 PM

  • Problems setting up ACL in 11g

    Hello,
    we recently updated from 10g to 11g. In our db we have a job, which calls a procedure, which checks if all mails from our application have been sent probably, if not it sends out a mail via a different mail server to admins, so they can check what the issue was.
    This worked fine in 10g. In 11g I've learned I need to set up the ACL to be able to connect to the mail Server. This is what I've done:
    Since the job, mentioned above is running for user sys i set up the ACL for the user sys.
    begin
      if dbms_db_version.ver_le_10_2 then
        null;
      else
        begin
          dbms_network_acl_admin.drop_acl(
            acl =>         'apex-network.xml'
        exception
          when others then null;
        end;
        dbms_network_acl_admin.create_acl(
          acl =>         'apex-network.xml',
          description => 'Network-Connects for system check',
          principal =>   'SYS',
          is_grant =>    true,
          privilege =>   'connect'
        DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
          acl =>         'apex-network.xml',
          principal =>   'SYS',
          is_grant  =>   true,
          privilege =>   'resolve'
        dbms_network_acl_admin.assign_acl(
          acl =>         'apex-lcmcc-network.xml',
          host =>        '123.456.78.99'
      end if;
    end;
    show error
    commit;
    The statement completed successfully. And i checked if the access is granted with the following statement:
    SELECT
    FROM
      user_network_acl_privileges,
      TABLE(DBMS_NETWORK_ACL_UTILITY.DOMAINS('123.456.78.99'))
    ORDER BY
      DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(column_value) desc,
      lower_port,                                             
      upper_port;
    I see now for the configured host and all subdomains user sys has the privillege resolve and connect granted.
    When i run the  procedure, which should sent the mails i still get the error ORA-24247: network access denied by access control list (ACL).
    Here is the relevant code from the procedure:
    BEGIN
              c := UTL_SMTP.OPEN_CONNECTION('123.456.78.99');
              UTL_SMTP.HELO(c, 'xxx.de');
              UTL_SMTP.MAIL(c, '[email protected]');
              UTL_SMTP.RCPT(c, p_rcpt);
              UTL_SMTP.OPEN_DATA(c);
              send_header('From',    p_from);
              send_header('To',      p_rcpt);
              send_header('Subject', p_subject);
              UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF||p_message );
              UTL_SMTP.CLOSE_DATA(c);
              UTL_SMTP.QUIT(c);
            EXCEPTION
              WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
                BEGIN
                  UTL_SMTP.QUIT(c);
                EXCEPTION
                  WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
                    NULL; -- When the SMTP server is down or unavailable, we don't have
                          -- a connection to the server. The QUIT call will raise an
                          -- exception that we can ignore.
                END;
                raise_application_error(-20000,
                  'Failed to send mail due to the following error: ' || sqlerrm);
            END;
    Please forgive me if i miss out important information you need to assist me in this endavor, i will try to deliver them shortly.
    Any sugesstions are much apreciated.
    Thanks in advance.

    >Since the job, mentioned above is running for user sys i set up the ACL for the user sys.
    SYS schema is reserved for Oracle maintenance & upgrades.
    You should NEVER make or modify objects within the SYS schema.

  • How to mail pdf file from oracle database 11g

    Hi,
    Using following code to send pdf file from oracle database.
    DECLARE
    v_From VARCHAR2(80) := '[email protected]';
    v_Recipient VARCHAR2(80) := '[email protected]';
    v_Subject VARCHAR2(80) := 'test subject';
    v_Mail_Host VARCHAR2(30) := '116.214.31.249';
    v_Mail_Conn sys.utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    v_Mail_Conn := sys.utl_smtp.Open_Connection(v_Mail_Host, 26);
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
    sys.utl_smtp.Mail(v_Mail_Conn, v_From);
    sys.utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
    sys.utl_smtp.Data(v_Mail_Conn,
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: ' || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: ' || v_Recipient || crlf ||
    'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'some message text'|| crlf ||     -- Message body
    'more message text'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachment
    crlf ||
    '-------SECBOUND--'               -- End MIME mail
    sys.utl_smtp.Quit(v_mail_conn);
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    Above code executed successfully and mail is send to recipient but file is corrupted.
    I think it doesn't pick file from specified location, attachment name is appearing like this 'D:mailpdfsample.pdf
    Oracle Database : 11g R2
    O.S : windows 7 Professional
    Thanks in Advance

    parapr wrote:
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);The above violates RFC 5321 section 4.1.1.1
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||Invalid Mime header above. Filename are logical. Not physical. Loose the drive and directory names. The filename is there to name the Mime body's content.
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachmentHow is the above PDF content? This is a string containing the text CSV,file,attachement. Which means when this is what is saved as a PDF file by the mail reader.
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;Silly. Why change meaningful exceptions into a generic meaningless exception?? That does not make any sense.

  • Hyperlinks in 11g (11.1.1.7)

    I'm reposting a post from 2 years ago because, as far as I can tell, there is no solution. I'd like to know if anyone has successfully implemented hyperlinks in BIP 11g.
    Can anyone share the method of calling a BIP 11g report from a hyperlink in an RTF file, and passing a parameter into that target report?
    I have a BIP report that includes the REGION field, which I want to define as a hyperlink. I want to click on one of the values of REGION, and have it open a second BIP report, passing the clicked value into the RGN parameter in that second report.
    The method in 10g was reasonably simple. We could assign the basic URL to a variable, then pass in an argument, like this:
    Defining the variable: <?variable:Drill_Rgn;string('http://localhost:9704/path_to_BIP_report')?>
    Hyperlink to call the report, passing the REGION field into the RGN parameter: {$Drill_Rgn}?RGN={REGION}
    In 11g, the URL is significantly different, and has been made MUCH more complex. Instead of the parameter being passed in using the standard '=' method as it was in 10g, the 11g URL has the parameter imbedded inside the URL, as follows:
    http://localhost:9704/analytics/saw.dll?bipublisherEntry&Action=open&itemType=.xdo&bipPath=%2F~retro901%2F_filters%2FRetrospectives%2FSubRegion_Sales.xdo&bipParams={"_xmode":"2","_xpf":"","_xpt":"0","_xdo":"%2F~retro901%2F_filters%2FRetrospectives%2FSubRegion_Sales.xdo","*_paramsRGN":"Central"*,"_xt":"Basic1","_xf":"html","_xautorun":"true"}
    Notice the inclusion (bolded) of _paramsRGN"."Central"*, where Central is a value of my REGION field in the XML. The value is in double-quotes, and is imbedded within the URL. This is the exact code copied from the Share Report Link option on the BIP viewer screen when Central is the value of the RGN parameter.
    Based on ideas from the documentation, I have tried replacing "Central" with: {REGION}, {$REGION}, REGION, %REGION, "{REGION}", "{$REGION}", "REGION", and "%REGION". No luck. The URL does not get formed properly (i.e. the field value is not substituted into the URL). I've also tried the old (10g) syntax. Nothing I've tried will replace the default value of RGN as specified in the data model.
    What is the correct method, in 11g, for calling a BI Publisher report from a hyperlink in an RTF file, and passing a field value into a parameter?

    Hi all,
    does anyone know whether there is any system component pre-requisite, apart from installing xdk, in order for acl to work?
    I have this question because after trying different methods we finally made utl_smtp worked on a testing server two days ago (without exactly know what made it work). Then, we tried to redo the whole process (i.e. create brand new database, import data, create acl, run the email function). Out of luck, we fell back to ORA-24247: network access denied by access control list (ACL) problem again. we compared the two databases but found no clue why one working another failed.
    By checking the result of the two databases for the following
    select host, lower_port, upper_port, acl
    from dba_network_acls;
    select principal, privilege, is_grant, acl
    from dba_network_acl_privileges;
    acl on both are the same
    Is there any thing we missed out? any hidden pre-requisite?
    This is urgent. Could somebody help? please
    Some more update:
    the database (say X) where acl works has "SYSTEM" as one of the owners of 'UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_INADDR' but in database (say Y) where acl doesn't work "SYSTEM" is not part of owner of 'UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_INADDR'
    in X, acl is granted to a role, email invoker with such role can send email successfully;
    in Y, both acl on user and acl on role do not work at all.
    Edited by: bsmt on May 5, 2010 7:46 PM

  • 10g to 11g  import problem NETWORK_ACLS

    (I didn't mean to cross post this I just put it in the wrong place at first. it belongs here.. sorry 'bout that.)
    I'm uprading from 10 to 11g and have a problem importing. The table I'm trying to import has a trigger in it that uses the UTL_SMTP package. When I import I get the following:
    . . importing table "MISSINGSPEND"
    IMP-00058: ORACLE error 24247 encountered
    ORA-24247: network access denied by access control list (ACL)
    ORA-06512: at "SYS.UTL_INADDR", line 4
    ORA-06512: at "SYS.UTL_INADDR", line 35
    ORA-06512: at "+schema+.MISSINGSPEND_TRIGGER", line 9
    I've done some research and discovered a new 'feature' in 11g - network acls. So, I created/executed this script:
    begin
    dbms_network_acl_admin.create_acl (
    acl => 'connect.xml',
    description => 'Allow connect to anything',
    principal => 'SYSTEM',
    is_grant => TRUE,
    privilege => 'connect'
    commit;
    end;
    begin
    dbms_network_acl_admin.assign_acl(
    acl => 'connect.xml',
    host => '*',
    upper_port => null,
    lower_port => null);
    end;
    begin
    dbms_network_acl_admin.add_privilege(
    acl => 'connect.xml',
    principal => 'MY_USER',
    is_grant => TRUE,
    privilege => 'connect');
    commit;
    end;
    begin
    dbms_network_acl_admin.create_acl (
    acl => 'resolve.xml',
    description => 'Allow inet address lookup ',
    principal => 'SYSTEM',
    is_grant => TRUE,
    privilege => 'resolve'
    commit;
    end;
    begin
    dbms_network_acl_admin.assign_acl(
    acl => 'resolve.xml',
    host => '*',
    upper_port => null,
    lower_port => null);
    end;
    begin
    dbms_network_acl_admin.add_privilege(
    acl => 'resolve.xml',
    principal => 'MY_USER',
    is_grant => TRUE,
    privilege => 'resolve');
    commit;
    end;
    quit;
    There are basicall only two acls that can be fine tuned to the host/port level. The way I have it, I should be able to connect/resolve anything ... I Think.
    Am I right? Is my script correct? What else could be wrong?
    Thanks. -Erik.

    Ok, but there's not really much difference. I admit that SYSTEM does't necessarily need this privilege but...whatever.
    So now it looks like this:
    connect / as sysdba;
    begin
    dbms_network_acl_admin.drop_acl(acl => 'resolve.xml');
    dbms_network_acl_admin.drop_acl(acl => 'connect.xml');
    end;
    begin
    dbms_network_acl_admin.create_acl (
    acl => 'connect.xml',
    description => 'Allow CONNECT',
    principal => 'MY_USER',
    is_grant => TRUE,
    privilege => 'connect'
    commit;
    end;
    begin
    dbms_network_acl_admin.assign_acl(
    acl => 'connect.xml',
    host => '*',
    upper_port => null,
    lower_port => null);
    end;
    begin
    dbms_network_acl_admin.create_acl (
    acl => 'resolve.xml',
    description => 'Allow inet address lookup ',
    principal => 'MY_USER',
    is_grant => TRUE,
    privilege => 'resolve'
    commit;
    end;
    begin
    dbms_network_acl_admin.assign_acl(
    acl => 'resolve.xml',
    host => '*',
    upper_port => null,
    lower_port => null);
    end;
    grant execute on utl_smtp to MY_USER;
    grant execute on utl_inaddr to MY_USER;
    quit;
    and when I try the import i get this:
    . . importing table "MISSINGSPEND"
    IMP-00058: ORACLE error 24247 encountered
    ORA-24247: network access denied by access control list (ACL)
    ORA-06512: at "SYS.UTL_INADDR", line 4
    ORA-06512: at "SYS.UTL_INADDR", line 35
    ORA-06512: at "MY_USER.MISSINGSPEND_TRIGGER", line 9
    ORA-04088: error during execution of trigger MY_USER.MISSINGSPEND_TRIGGER'
    I still haven't finished reading all the stuff that was posted earlier. and thanks for your reply. -Erik.
    (could it be that SYS needs to be included in the ACL?)
    Edited by: user618403 on Mar 22, 2011 10:37 AM
    Edited by: user618403 on Mar 22, 2011 10:37 AM

  • Oracle Gird Control 11g (11.1.0.1.0) having "No Data Found" in SOA SCA

    Dear All,
    Having strange problems while using Weblogic Middleware Targets in Grid Control. After successful registration of new WebLogic Domain, I can not control/administer managed servers, SOA composites, WLS domain application deployments as after right click I get context menu in Firefox (FF 3.6.x, FF 4) darked and disabled. The context menu is rendered, but user can not choose item. Only works properly in Google Chrome.
    Next problem that using Weblogic Middleware Targets in Grid Control any metrics as throughout graph, error instances, services & references, component metrics, response and load graphs, CPU, memory ... all data are unavailable or no data fetch, or no data found.
    What we can see is only item status if it is running or not.
    When I login directly to WLS console, or EM the statistics and graphs are present. No logs, no error reported by GC 11g.
    BRs,
    IBU

    Hi all,
    does anyone know whether there is any system component pre-requisite, apart from installing xdk, in order for acl to work?
    I have this question because after trying different methods we finally made utl_smtp worked on a testing server two days ago (without exactly know what made it work). Then, we tried to redo the whole process (i.e. create brand new database, import data, create acl, run the email function). Out of luck, we fell back to ORA-24247: network access denied by access control list (ACL) problem again. we compared the two databases but found no clue why one working another failed.
    By checking the result of the two databases for the following
    select host, lower_port, upper_port, acl
    from dba_network_acls;
    select principal, privilege, is_grant, acl
    from dba_network_acl_privileges;
    acl on both are the same
    Is there any thing we missed out? any hidden pre-requisite?
    This is urgent. Could somebody help? please
    Some more update:
    the database (say X) where acl works has "SYSTEM" as one of the owners of 'UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_INADDR' but in database (say Y) where acl doesn't work "SYSTEM" is not part of owner of 'UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_INADDR'
    in X, acl is granted to a role, email invoker with such role can send email successfully;
    in Y, both acl on user and acl on role do not work at all.
    Edited by: bsmt on May 5, 2010 7:46 PM

  • ORACLE 11g R1 Email Alerts

    Hi
    I would like to send sql staments result set in a email to mutiple recepients. Result can be in body of email /xls attachment. is there any pl.sql scripts available to perform same in oracle 11g r1.
    Thanks
    Raj

    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/u_smtp.htm
    Examples
    The following example illustrates how UTL_SMTP is used by an application to send e-mail. The application connects to an SMTP server at port 25 and sends a simple text message.
    DECLARE
      c UTL_SMTP.CONNECTION;
      PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
      BEGIN
        UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
      END;
    BEGIN
      c := UTL_SMTP.OPEN_CONNECTION('smtp-server.acme.com');
      UTL_SMTP.HELO(c, 'foo.com');
      UTL_SMTP.MAIL(c, '[email protected]');
      UTL_SMTP.RCPT(c, '[email protected]');
      UTL_SMTP.OPEN_DATA(c);
      send_header('From',    '"Sender" <[email protected]>');
      send_header('To',      '"Recipient" <[email protected]>');
      send_header('Subject', 'Hello');
      UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || 'Hello, world!');
      UTL_SMTP.CLOSE_DATA(c);
      UTL_SMTP.QUIT(c);
    EXCEPTION
      WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
        BEGIN
          UTL_SMTP.QUIT(c);
        EXCEPTION
          WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
            NULL; -- When the SMTP server is down or unavailable, we don't have
                  -- a connection to the server. The QUIT call will raise an
                  -- exception that we can ignore.
        END;
        raise_application_error(-20000,
          'Failed to send mail due to the following error: ' || sqlerrm);
    END;

  • 11g Upgrade - Network ACL

    I want to upgrade my oracle 10g database to 11g. the utlui112.sql script shows following -
    WARNING: --> Database contains schemas with objects dependent on network packages.
    .... Refer to the Upgrade Guide for instructions to configure Network ACLs.
    .... USER MDMSYS has dependent objects.
    According to documentation , it is not clear whether I need to install XML DB before upgrade or after upgrade to 11g.
    I run the following query and result is as follows -
    SQL >SELECT * FROM DBA_DEPENDENCIES WHERE referenced_name IN ('UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_INADDR')
    AND owner NOT IN ('SYS','PUBLIC','ORDPLUGINS');
    OWNER NAME TYPE REFERENCED_OWNER REFERENCED_NAME REFERENCED_TYPE
    REFERENCED_LINK_NAME DEPE
    MDMSYS MDM_JOB PACKAGE BODY PUBLIC UTL_TCP SYNONYM
    HARD
    MDMSYS MDM_JOB PACKAGE BODY MDMSYS UTL_TCP NON-EXISTENT
    Can someone plaease help on how I can configure the network ACLs?

    Hi ,
    You can grant to a network and not necessary to grant each machines IP details.
    Also this has to be granted to users or the principal is the schema who will be executing this utl_smtp.
    If there are multiple users, then you need to grant access to each user.
    You need to configure below steps to grant access to the user for utl operations.
    This is a new security feature to 11g.
    Please review below document :
    Oracle® Database Security Guide
    11g Release 1 (11.1)
    Part Number B28531-06
    4 Configuring Privilege and Role Authorization
    Managing Fine-Grained Access to External Network Services
    URL : http://download.oracle.com/docs/cd/B28359_01/network.111/b28531/authorization.htm#CIHDAJDJ
    A example of the setting:
    =================
    If you are creating the ACL for the first time, you can directly go to step (d).
    Please replace the values in < > with your environment values.
    a. Drop the user privilege:(please run the below for all the users who are granted connect privilege).
    BEGIN
    DBMS_NETWORK_ACL_ADMIN.delete_privilege (
    acl => '<mailserver_acl.xml>',
    principal => '<MYUSER>',
    is_grant => FALSE,
    privilege => 'connect');
    COMMIT;
    END;
    b. Unassign the network details from ACL (The ip address are only example, please replace with the
    values you have specified)
    BEGIN
    DBMS_NETWORK_ACL_ADMIN.unassign_acl (
    acl => '<mailserver_acl.xml>',
    host => '<192.168.2.3>',
    lower_port => <25>,
    upper_port => <25>);
    COMMIT;
    END;
    c. Drop the ACL
    BEGIN
    DBMS_NETWORK_ACL_ADMIN.drop_acl (
    acl => '<mailserver_acl.xml>');
    COMMIT;
    END;
    d. Create the acl again fresh:
    BEGIN
    DBMS_NETWORK_ACL_ADMIN.create_acl (
    acl => 'mailserver_acl.xml',
    description => 'Mailserver ACL',
    principal => '<MYUSER>',
    is_grant => TRUE,
    privilege => 'connect',
    start_date => SYSTIMESTAMP,
    end_date => NULL);
    COMMIT;
    END;
    e. Assign the acl to the network:(please have the ip address modified to correct IP of the machine where this utl package is targetted run.)
    for example IP/hostname of mail server should be there for UTL_SMTP to execute.
    BEGIN
    DBMS_NETWORK_ACL_ADMIN.assign_acl (
    acl => 'mailserver_acl.xml',
    host => '<192.168.2.3>',
    lower_port => <25>,
    upper_port => <25>);
    COMMIT;
    END;
    f.Test the package.
    Thanks,
    Sathya

Maybe you are looking for