Dear All,
This is my Oracle client configuration
<<
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
PL/SQL Release 8.1.5.0.0 - Production
CORE Version 8.1.3.0.0 - Production
TNS for Solaris: Version 8.1.5.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production
>>
I connect to a Oracle 8i server in a separate machine.
I need to send mails from the Oracle database itself. My aim is to write a procedure which shall pick up e-mail ids and the subject and message from a table and send it automatically. Using DBMS_JOB.SUBMIT I shall execute this procedure at some specified interval. The procedure I have written for this is as under after connecting to a specific application username .
<<
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_from varchar2 := 'oracle',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('mailserver', 25); -- open the SMTP port
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'HELO localhost');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
rc := utl_tcp.write_line(c, '');
rc := utl_tcp.write_line(c, msg_text);
rc := utl_tcp.write_line(c, '.'); -- End of message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'QUIT');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
utl_tcp.close_connection(c); -- Close the connection
EXCEPTION
when others then
raise_application_error(-20000,
'Unable to send e-mail message from pl/sql');
END;
/
>>
Assumed that "mailserver" is the mailserver we use for sending our normal mails using Eudora/Outlook Express etc from the machine where my Oracle Client also resides.
The errors while creating the procedure are :
<<
SQL> show errors
Errors for PROCEDURE SEND_MAIL:
LINE/COL ERROR
-------- -------------------------------------------------------------
7/6 PLS-00201: identifier 'UTL_TCP.CONNECTION' must be declared
7/6 PL/SQL: Item ignored
10/3 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
10/3 PL/SQL: Statement ignored
11/3 PL/SQL: Statement ignored
11/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
12/3 PL/SQL: Statement ignored
12/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
13/3 PL/SQL: Statement ignored
13/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
14/3 PL/SQL: Statement ignored
14/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
15/3 PL/SQL: Statement ignored
15/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
16/3 PL/SQL: Statement ignored
16/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
17/3 PL/SQL: Statement ignored
17/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
18/3 PL/SQL: Statement ignored
>>
What I feel is that the package UTL_TCP is missing. If I happen to find this package do I create it in the database in my application user schema or do I need to log in as sys or system user. Also learnt that I need to have the JServer option installed. What does that mean?? Does it mean I shall have to run the Oracke Installer once again and install thsi option ?? If yes then at the server end or at the Client end??
I would appreciate an answer after somebody has actually done and succeded in what I intend to do.
Regards
Prosenjit
This is my Oracle client configuration
<<
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
PL/SQL Release 8.1.5.0.0 - Production
CORE Version 8.1.3.0.0 - Production
TNS for Solaris: Version 8.1.5.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production
>>
I connect to a Oracle 8i server in a separate machine.
I need to send mails from the Oracle database itself. My aim is to write a procedure which shall pick up e-mail ids and the subject and message from a table and send it automatically. Using DBMS_JOB.SUBMIT I shall execute this procedure at some specified interval. The procedure I have written for this is as under after connecting to a specific application username .
<<
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_from varchar2 := 'oracle',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('mailserver', 25); -- open the SMTP port
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'HELO localhost');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
rc := utl_tcp.write_line(c, '');
rc := utl_tcp.write_line(c, msg_text);
rc := utl_tcp.write_line(c, '.'); -- End of message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'QUIT');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
utl_tcp.close_connection(c); -- Close the connection
EXCEPTION
when others then
raise_application_error(-20000,
'Unable to send e-mail message from pl/sql');
END;
/
>>
Assumed that "mailserver" is the mailserver we use for sending our normal mails using Eudora/Outlook Express etc from the machine where my Oracle Client also resides.
The errors while creating the procedure are :
<<
SQL> show errors
Errors for PROCEDURE SEND_MAIL:
LINE/COL ERROR
-------- -------------------------------------------------------------
7/6 PLS-00201: identifier 'UTL_TCP.CONNECTION' must be declared
7/6 PL/SQL: Item ignored
10/3 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
10/3 PL/SQL: Statement ignored
11/3 PL/SQL: Statement ignored
11/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
12/3 PL/SQL: Statement ignored
12/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
13/3 PL/SQL: Statement ignored
13/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
14/3 PL/SQL: Statement ignored
14/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
15/3 PL/SQL: Statement ignored
15/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
16/3 PL/SQL: Statement ignored
16/9 PLS-00201: identifier 'UTL_TCP.WRITE_LINE' must be declared
17/3 PL/SQL: Statement ignored
17/24 PLS-00201: identifier 'UTL_TCP.GET_LINE' must be declared
18/3 PL/SQL: Statement ignored
>>
What I feel is that the package UTL_TCP is missing. If I happen to find this package do I create it in the database in my application user schema or do I need to log in as sys or system user. Also learnt that I need to have the JServer option installed. What does that mean?? Does it mean I shall have to run the Oracke Installer once again and install thsi option ?? If yes then at the server end or at the Client end??
I would appreciate an answer after somebody has actually done and succeded in what I intend to do.
Regards
Prosenjit