暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle utl_smtp发送电子邮件问题,同时增加抄送中的电子邮件数量

askTom 2017-02-20
428

问题描述

Recently I moved to oracle database Release 12.1.0.2.0, while using below mentioned code for send email through utl_smtp it works fine but when the number of emails in cc increase it generate the error ora-29278 smtp transient error 421 service not available.
Same code running fine on oracle Release 10.2.0.1.0.

Kindly guide me which change I have to made to run the code with more then 100 numbers of email in CC.


CREATE OR REPLACE PROCEDURE send_mail_image (p_to          IN VARCHAR2,
                                           p_from        IN VARCHAR2,
                                           p_cc          IN VARCHAR2,
                                           p_subject     IN VARCHAR2,
                                           p_text_msg    IN VARCHAR2 DEFAULT NULL,
                                           p_attach_name IN VARCHAR2 DEFAULT NULL,
                                           p_attach_blob IN BLOB ) is
    conn                 utl_smtp.connection;
    BOUNDARY             VARCHAR2 (256) := '-----090303020209010600070908';
    i                    pls_integer;
    len                  pls_integer;
    buff_size            pls_integer := 57;
    l_raw                raw(57);
    p_image              blob  := p_attach_blob;
    p_smtp_host          VARCHAR2(30) := '192.168.11.6';
    l_message            VARCHAR2(32767) :=  '



'||p_text_msg||'

banner '; v_emails varchar2(5000); v_pos number := 0 ; v_email varchar2(100); begin conn := utl_smtp.open_connection(p_smtp_host, 25); UTL_SMTP.helo (conn, p_smtp_host); UTL_SMTP.mail (conn, p_from); --UTL_SMTP.rcpt (conn, p_to); if p_to is not null then v_emails := p_to; Begin v_pos := instr(v_emails,';') ; if v_pos = 0 then v_emails := v_emails||';'; end if; v_pos := instr(v_emails,';') ; if v_pos > 0 then v_email := substr(v_emails,1,v_pos-1); while v_pos > 0 loop v_pos := v_pos + 1; UTL_SMTP.rcpt (conn,v_email); v_emails := substr(v_emails,v_pos); v_pos := instr(v_emails,';') ; v_email := substr(v_emails,1,v_pos-1); end loop; End if; end; v_email := null; v_emails := null; End if; if p_cc is not null then v_emails := p_cc; Begin v_pos := instr(v_emails,';') ; if v_pos = 0 then v_emails := v_emails||';'; end if; v_pos := instr(v_emails,';') ; if v_pos > 0 then v_email := substr(v_emails,1,v_pos-1); while v_pos > 0 loop v_pos := v_pos + 1; UTL_SMTP.rcpt (conn,v_email); v_emails := substr(v_emails,v_pos); v_pos := instr(v_emails,';') ; v_email := substr(v_emails,1,v_pos-1); end loop; End if; end; v_email := null; v_emails := null; End if; UTL_SMTP.open_data (conn); UTL_SMTP.write_data (conn, 'From' || ': ' || p_from || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, 'To' || ': ' || p_to || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, 'Cc' || ': ' || p_cc || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, 'MIME-Version: 1.0' || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, 'Subject: '||p_subject || UTL_TCP.CRLF) ; UTL_SMTP.write_data (conn, 'Content-Type: multipart/mixed; boundary="' || BOUNDARY || '"' || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, UTL_TCP.CRLF); UTL_SMTP.write_data (conn, '--' || BOUNDARY || UTL_TCP.CRLF ); UTL_SMTP.write_data (conn, 'Content-Type: text/html; charset=US-ASCII'|| UTL_TCP.CRLF ); UTL_SMTP.write_data (conn, UTL_TCP.CRLF); UTL_SMTP.write_data (conn, l_message); UTL_SMTP.write_data (conn, UTL_TCP.CRLF); UTL_SMTP.write_data (conn, '--' || BOUNDARY || UTL_TCP.CRLF ); UTL_SMTP.write_data (conn, 'Content-Type: image/jpg;'|| UTL_TCP.CRLF ); UTL_SMTP.write_data (conn, 'Content-Disposition: inline; filename= "'|| p_attach_name ||'"'|| UTL_TCP.CRLF); UTL_SMTP.WRITE_DATA (conn, 'Content-ID: ' || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, 'Content-Transfer-Encoding' || ': ' || 'base64' || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, UTL_TCP.CRLF); i := 1; len := dbms_lob.getlength(p_image); while i < len loop dbms_lob.read(p_image, buff_size, i, l_raw); utl_smtp.write_raw_data(conn, utl_encode.base64_encode(l_raw)); utl_smtp.write_data(conn, utl_tcp.crlf); i := i + buff_size; end loop; utl_smtp.write_data(conn, utl_tcp.crlf); UTL_SMTP.write_data (conn, '--' || BOUNDARY || '--' || UTL_TCP.CRLF); UTL_SMTP.write_data (conn, UTL_TCP.CRLF); UTL_SMTP.close_data (conn); UTL_SMTP.quit (conn); end Send_mail_image;
复制

专家解答

抱歉,我没有100可以测试的电子邮件地址。

它似乎不是接口中的固有限制,因为我对utl_smtmp.rcpt进行了500调用 (尽管所有地址都相同),没有任何问题。

因此,它 * 可能 * 是您拥有的邮件服务器/配置的限制/限制,或者 * 可能 * 是一个问题,当收件人都是不同的 (我无法真正测试)。

在任何一种情况下,让我感到奇怪的是,您将从数据库中管理它-通常对于这样的卷,您将有一个组设置作为分发列表。

但是我建议您在支持下记录电话-他们也许可以为您提供进一步的帮助。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论