I am trying to send email to user to notify password expiration in my 9i database; however, I am not able to send email by using utl_smtp package.
These are what I am trying to do:
1. list all users whose passwords are expirying in 12 days
2. send one email to designated users with this list of users.
Here are my codes:
CREATE OR REPLACE PROCEDURE sendmail
( sender IN VARCHAR2,
recipient IN VARCHAR2,
subject IN VARCHAR2,
message IN varchar2)
IS
mailhost VARCHAR2(100) := 'oracleserver';
c UTL_SMTP.Connection;
BEGIN
dbms_output.put_line('message: '|| message);
EXCEPTION
WHEN UTL_SMTP.transient_error OR UTL_SMTP.permanent_error THEN
UTL_SMTP.quit(c);
raise_application_error(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
WHEN OTHERS THEN
raise_application_error(-20001, 'The following error has occured: ' || sqlerrm);
END;
/
create or replace procedure ck_expiry AS
Cursor c_getexpiry is
select username,expiry_date
from dba_users;
When I execute the ck_expiry procedure, I got no email but these returns:
message: MSGING-7
METARW-7
METARO-7
METADW-7
META-7
If I execute sendmail procedure directly I got email:
exec sendmail (sender=>'oracle@oracleserver.com',recipient=>'user1@yahoo.com',subject=> 'Password Notification',message=>'MSGING-7'||chr(10)||'METARW-7'||chr(10)||'METARO-7'||chr(10)||'METADW-7'||chr(10)||'META-7');
Are there limitations for utl_smtp.write_data? How can I go around it? Any help is appreciated.
Bookmarks