I want to send newly inserted entries of audit table through EMAIL along with newly inserted data in CSV format. I am using after insert trigger to keep track of inserted rows, but my code is unable to send email. It's throwing error ORA-29279 : SMTP permanent error : 550 RBL: http://www.barracudanetwork.com/reputation/>pr=1&ip=xxx.xxx.xxx.xx
I am using my organization's email server. Below is my Code:
CREATE OR REPLACE TRIGGER emp_after_insert
AFTER INSERT
ON scott.emp
FOR EACH ROW
enable
DECLARE
v_username varchar2(10);
v_no number(4);
v_name varchar2(10);
DIR_NAME VARCHAR2(10):= 'UTL_FILE';
FILE_NAME VARCHAR2(10):= 'EINFO.csv';
F1 UTL_FILE.FILE_TYPE;
PRESENT BOOLEAN;
FLENGTH NUMBER;
BSIZE PLS_INTEGER;
CNTR NUMBER:=0;
BEGIN
insert into scott.emp_audit(id,name,insertion_date) values(:new.empno,:new.ename,sysdate);
dbms_output.put_line('inserted');
UTL_FILE.FGETATTR(LOCATION=>DIR_NAME,FILENAME=>FILE_NAME,
FEXISTS=>PRESENT,FILE_LENGTH=>FLENGTH,
BLOCK_SIZE=>BSIZE);
IF PRESENT THEN
F1:=UTL_FILE.FOPEN(DIR_NAME,FILE_NAME,'a'); ------APPEND MODE-
UTL_FILE.PUT_LINE(F1,RPAD('',LENGTH(CURRENT_TIMESTAMP),''));
ELSE
F1:=UTL_FILE.FOPEN(DIR_NAME,FILE_NAME,'W'); -----WRITE MODE-----
END IF;
UTL_FILE.PUT_LINE(F1,RPAD(:new.empno,10,' ')||RPAD(:new.ename,10,' '));
DBMS_OUTPUT.PUT_LINE('FILE CREATED ...'||FILE_NAME||'...AS ON ...'||CURRENT_TIMESTAMP);
UTL_FILE.FCLOSE(F1);
UTL_MAIL.send_attach_varchar2 (
sender => '[email protected]',
recipients => '[email protected]',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!',
attachment => 'The is the contents of the attachment.',
att_filename => 'C:\export\EINFO.csv'
);
end;
I also execute ALTER SYSTEM SET smtp_out_server='mail.abc.com'
Also executed the scripts of utlmail and prvtmail. Please Help!