0

我想通过 EMAIL 发送新插入的审计表条目以及 CSV 格式的新插入数据。我正在使用 after insert 触发器来跟踪插入的行,但我的代码无法发送电子邮件。它抛出错误ORA-29279:SMTP 永久错误:550 RBL: http ://www.barracudanetwork.com/reputation/ >pr=1&ip=xxx.xxx.xxx.xx

我正在使用我组织的电子邮件服务器。以下是我的代码:

   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       => 'abc@gmail.com',
       recipients   => 'xyz123@gmail.com',
       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;

我也执行ALTER SYSTEM SET smtp_out_server='mail.abc.com'

还执行了 utlmail 和 prvtmail 的脚本。请帮忙!

4

0 回答 0