UTL_SMTP or UTL_MAIL

Hi All,
I need to send message from OA Framework through pl/sql procedure. Our database is 10g.
What would you recommend to me UTL_SMTP or UTL_Mail. I have a code in which i able to send mail but how to send mail with attachment.
If anyone can arrange some working code of it then it is really appreciable.
Thanks
--Ajay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Hmm... Then I can share with you source of procedure
create or replace procedure email_files(from_name varchar2,
                      to_names varchar2,
                      subject varchar2,
                      message varchar2 default null,
                      html_message varchar2 default null,
                      cc_names varchar2 default null,
                      bcc_names varchar2 default null,
                      filename1 varchar2 default null,
                      filetype1 varchar2 default ‘text/plain’,
                      filename2 varchar2 default null,
                      filetype2 varchar2 default ‘text/plain’,
                      filename3 varchar2 default null,
                      filetype3 varchar2 default ‘text/plain’)
is
   — Change the SMTP host name and port number below to your own values,
   — if not localhost on port 25:
   smtp_host          varchar2(256) := ‘####################’;
   smtp_port          number := 25;
   boundary           constant varchar2(256) := ‘CES.Boundary.DACA587499938898′;
   recipients         varchar2(32767);
   directory_path     varchar2(256);
   file_name          varchar2(256);
   crlf               varchar2(2):= chr(13) || chr(10);
   mesg               varchar2(32767);
   conn               UTL_SMTP.CONNECTION;
   type varchar2_table is table of varchar2(256) index by binary_integer;
   file_array         varchar2_table;
   type_array         varchar2_table;
   i                  binary_integer;
   PROCEDURE split_path_name(file_path IN VARCHAR2, directory_path OUT VARCHAR2,
      file_name OUT VARCHAR2) IS
      pos number;
   begin
      — Separate the filename from the directory name
      pos := instr(file_path,’/',-1);
      if pos = 0 then
         pos := instr(file_path,’\',-1);
      end if;
      if pos = 0 then
         directory_path := null;
      else
         directory_path := substr(file_path,1,pos - 1);
      end if;
      file_name := substr(file_path,pos + 1);
   end;
   — Procedure to append a file’s contents to the e-mail
   PROCEDURE append_file(directory_path IN VARCHAR2, file_name IN VARCHAR2,
      file_type IN VARCHAR2, conn IN OUT UTL_SMTP.CONNECTION) IS
      generated_name  varchar2(30) := ‘CESDIR’ || to_char(sysdate,’HH24MISS’);
      directory_name  varchar2(30);
      file_handle     utl_file.file_type;
      bfile_handle    bfile;
      bfile_len       number;
      pos             number;
      read_bytes      number;
      line            varchar2(1000);
      data            raw(200);
      my_code         number;
      my_errm         varchar2(32767);
   begin
      begin
         — Grant access to the directory, unless already defined, and open
         — the file (as a bfile for a binary file, otherwise as a text file).
         begin
            line := directory_path;
            select dd.directory_name into directory_name from dba_directories dd
               where dd.directory_path = line and rownum = 1;
         exception
            when no_data_found then
               directory_name := generated_name;
         end;
         if directory_name = generated_name then
            execute immediate ‘create or replace directory ‘ || directory_name ||
               ‘ as ”’ || directory_path || ””;
            execute immediate ‘grant read on directory ‘ || directory_name ||
               ‘ to public’;
         end if;
         if substr(file_type,1,4) != ‘text’ then
            bfile_handle := bfilename(directory_name,file_name);
            bfile_len := dbms_lob.getlength(bfile_handle);
            pos := 1;
            dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
         else
            file_handle := utl_file.fopen(directory_name,file_name,’r');
         end if;
         — Append the file contents to the end of the message
         loop
            — If it is a binary file, process it 57 bytes at a time,
            — reading them in with a LOB read, encoding them in BASE64,
            — and writing out the encoded binary string as raw data
            if substr(file_type,1,4) != ‘text’ then
               if pos + 57 - 1 > bfile_len then
                  read_bytes := bfile_len - pos + 1;
               else
                  read_bytes := 57;
               end if;
               dbms_lob.read(bfile_handle,read_bytes,pos,data);
               utl_smtp.write_raw_data(conn,utl_encode.base64_encode(data));
               pos := pos + 57;
               if pos > bfile_len then
                  exit;
               end if;
            — If it is a text file, get the next line of text, append a
            — carriage return / line feed to it, and write it out
            else
               utl_file.get_line(file_handle,line);
               utl_smtp.write_data(conn,line || crlf);
            end if;
         end loop;
      — Output any errors, except at end when no more data is found
      exception
         when no_data_found then
            null;
         when others then
            my_code := SQLCODE;
            my_errm := SQLERRM;
            dbms_output.put_line(’Error code ‘ || my_code || ‘: ‘ ||
               my_errm);
      end;
      — Close the file (binary or text)
      if substr(file_type,1,4) != ‘text’ then
         dbms_lob.close(bfile_handle);
      else
         utl_file.fclose(file_handle);
      end if;
      if directory_name = generated_name then
         execute immediate ‘drop directory ‘ || directory_name;
      end if;
   end;
begin
   — Load the three filenames and file (mime) types into an array for
   — easier handling later
   file_array(1) := filename1;
   type_array(1) := filetype1;
   — Open the SMTP connection and set the From and To e-mail addresses
   conn := utl_smtp.open_connection(smtp_host,smtp_port);
   utl_smtp.helo(conn,smtp_host);
   recipients := from_name;
   utl_smtp.mail(conn,recipients);
   recipients := to_names;
   utl_smtp.rcpt(conn,recipients);
   utl_smtp.open_data(conn);
   — Build the start of the mail message
   mesg := ‘Date: ‘ || TO_CHAR(SYSDATE,’dd Mon yy hh24:mi:ss’) || crlf ||
      ‘From: ‘ || from_name || crlf ||
      ‘Subject: ‘ || subject || crlf ||
      ‘To: ‘ || to_names || crlf;
   mesg := mesg || ‘Mime-Version: 1.0′ || crlf ||
      ‘Content-Type: multipart/mixed; boundary=”‘ || boundary || ‘”‘ ||
      crlf || crlf ||
      ‘This is a Mime message, which your current mail reader may not’ || crlf ||
      ‘understand. Parts of the message will appear as text. If the remainder’ || crlf ||
      ‘appears as random characters in the message body, instead of as’ || crlf ||
      ‘attachments, then you”ll have to extract these parts and decode them’ || crlf ||
      ‘manually.’ || crlf || crlf;
   utl_smtp.write_data(conn,mesg);
   — Write the text message or message file, if any
   if message is not null then
      mesg := ‘–’ || boundary || crlf ||
         ‘Content-Type: text/plain; name=”message.txt”; charset=US-ASCII’ ||
          crlf ||
         ‘Content-Disposition: inline; filename=”message.txt”‘ || crlf ||
         ‘Content-Transfer-Encoding: 7bit’ || crlf || crlf;
      utl_smtp.write_data(conn,mesg);
      if substr(message,1,1) = ‘/’ then
         split_path_name(message,directory_path,file_name);
         append_file(directory_path,file_name,’text’,conn);
         utl_smtp.write_data(conn,crlf);
      else
         utl_smtp.write_data(conn,message || crlf);
      end if;
   end if;
   — Append the files
      if file_array(1) is not null then
         split_path_name(file_array(1),directory_path,file_name);
         — Generate the MIME boundary line according to the file (mime) type
         — specified.
         mesg := crlf || ‘–’ || boundary || crlf;
         if substr(type_array(1),1,4) != ‘text’ then
            mesg := mesg || ‘Content-Type: ‘ || type_array(1) ||
               ‘; name=”‘ || file_name || ‘”‘ || crlf ||
               ‘Content-Disposition: attachment; filename=”‘ ||
               file_name || ‘”‘ || crlf ||
               ‘Content-Transfer-Encoding: base64′ || crlf || crlf ;
         else
            mesg := mesg || ‘Content-Type: application/octet-stream; name=”‘ ||
               file_name || ‘”‘ || crlf ||
               ‘Content-Disposition: attachment; filename=”‘ ||
               file_name || ‘”‘ || crlf ||
               ‘Content-Transfer-Encoding: 7bit’ || crlf || crlf ;
         end if;
         utl_smtp.write_data(conn,mesg);
         — Append the file contents to the end of the message
         append_file(directory_path,file_name,type_array(1),conn);
         utl_smtp.write_data(conn,crlf);
      end if;
   — Append the final boundary line
   mesg := crlf || ‘–’ || boundary || ‘–’ || crlf;
   utl_smtp.write_data(conn,mesg);
   — Close the SMTP connection
   utl_smtp.close_data(conn);
   utl_smtp.quit(conn);
end;
/ Then execute
exec email_files(from_name=>’[email protected]’,to_names=>’[email protected]’, subject=> ‘mail subject’,filename1=>’test.tar’, filetype1=> ‘application/x-tar’);- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com

Similar Messages

  • Does Oracle 10g express edition supports UTL_SMTP

    Currently i'm using ORacle 10g Express edition, is it possible to send an automatic email once a value updates a table.
    Does 10gExpress edition supports UTL_SMTP or UTL_MAIL. If supports let me know how to configure in 10gExpress edition .

    It supports UTL_SMTP. You can check a couple of threads to see some demo usage of it.
    Re: How to send Email with attachments
    ~ Madrid

  • Error in executing UTL_MAIL

    Dear Gurus...I've tried both UTL_SMTP and UTL_MAIL, UTL_SMTP is working well and sending mails but following code of UTL_MAIL is giving the error which I can't guess, why?
    DECLARE
    CRLF CHAR(2) := CHR(10) || CHR(13);
    BEGIN
    UTL_MAIL.SEND(sender => '[email protected]',
    recipients => '[email protected]',
    cc => NULL,
    bcc => NULL,
    subject => 'Test Email',
    message => 'Test line1' || CRLF || CRLF || 'Test line2',
    mime_type => 'text/plain; charset=us-ascii',
    priority => 1);
    END;
    and the error is:
    ORA-29279: SMTP permanent error: 554 Message is not RFC compliant
    ORA-06512: at "SYS.UTL_SMTP", line 20
    ORA-06512: at "SYS.UTL_SMTP", line 98
    ORA-06512: at "SYS.UTL_SMTP", line 345
    ORA-06512: at "SYS.UTL_MAIL", line 577
    ORA-06512: at "SYS.UTL_MAIL", line 594
    ORA-06512: at line 4
    could u guess why this error is generating???
    P.S...I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production on MS-Windows Server-2003.

    Dear Sybrand...Yes I can read this RFC but not right now, I'll be happy if u can solve this problem without making me a book worm ;) I'ld like to add that I'm executing UTL_SMTP with the following code successfully:
    DECLARE
    v_From VARCHAR2(80) := '[email protected]';
    v_Recipient VARCHAR2(80) := '[email protected]; [email protected]';
    v_Subject VARCHAR2(80) := 'test mail with attachment';
    v_Mail_Host VARCHAR2(30) := 'mail.nishatmills.com';
    v_Mail_Conn utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
    utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
    utl_smtp.Mail(v_Mail_Conn, v_From);
    utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
    utl_smtp.Data(v_Mail_Conn,
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: ' || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: ' || v_Recipient || crlf ||
    crlf ||
    'Dear Shahid'||CHR(10)||'This is test mail through UTL_SMTP with attachment'||CHR(10)||'Regards '||CHR(10)||' M.Kamran Khan'|| crlf || -- Message body
    utl_smtp.Quit(v_mail_conn);
    EXCEPTION
    WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    So if UTL_SMTP can run successfully then why not UTL_MAIL as UTL_SMTP is working behid it.
    Does it need any Database configuration like any installation of a package?

  • How to setup and send mails using utl_mail on Oracle E-Biz R12

    Dear All
    There is a new requirement from client to setup and send mails using utl_mail utility on Oracle EBS R12.1.1
    What is utl_mail utility ? what is the difference between Workflow Notification Mailer and this utility/tool?
    What are etiquette's to pursue mail functionality in apps / db?
    - Chetan

    What is utl_mail utility
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm
    How to Use the UTL_MAIL Package [ID 269375.1]
    FAQ and Known Issues While Using UTL_SMTP and UTL_MAIL [ID 730746.1]
    Master Note For PL/SQL UTL_SMTP and UTL_MAIL Packages [ID 1137673.1]
    Workflow Notification Mailer:
    you can send email using workflow notification email procedures,These ar built into the system and only need some minor configuration. check Workflow Administrator's Guide, Chapter 2, Section: Setting Up Notification Mailers for more detail.

  • SMTP update in Oracle Database UTL_SMTP

    Hello All,
    We migrated to a new mail server with different host name since then my applications using UTIL_SMTP function quit Working...!
    I'm wondering where do we update the SMTP server settings in Oracle Database?
    I already updated Init.ora file but it's not working. Any help would be greatly appreciated...!
    Thanks
    Rao

    If you are using UTL_SMTP, not UTL_MAIL, then the name of the SMTP server would be specified in your code. The newer (and easier to use) UTL_MAIL package allows you to configure the SMTP server as an initialization parameter. If you look in the code, there should be a line where you call UTL_SMTP.OPEN_CONNECTION and pass in the SMTP server.
    Justin

  • UTL_SMTP with Sendmail: Solution for ORA-29278: SMTP transient error

    For those of you migrating from Windows or other platforms to Linux (Redhat Enterprise AS 3.0, in my case) and have email routines using UTL_SMTP, I have a hard-earned hint for you. If your email routines are not working when you try to use the local smtp service (sendmail) try the following at the SQL prompt.
    set serverout on
    declare
    c utl_smtp.connection;
    r utl_smtp.reply;
    begin
    c := utl_smtp.open_connection('local.email.server', 25);
    utl_smtp.helo(c,'local.email.server');
    end;
    If you get ORA-29278: SMTP transient error: 421 Service not available, try the following instead:
    set serverout on
    declare
    c utl_smtp.connection;
    r utl_smtp.reply;
    begin
    c := utl_smtp.open_connection('127.0.0.1', 25);
    utl_smtp.helo(c,'127.0.0.1');
    end;
    And you should get success. So you should specify the internal loopback IP address for the email hostname in the open_connection function. It will not work with anything else (servername, localhost, NIC IP).
    The reason for this is that there is a setting in the sendmail config file (/etc/mail/sendmail.mc) that causes sendmail to only listen on 127.0.0.1. As long as you aren't using sendmail as a relay, this isn't a problem.
    Just specify 127.0.0.1 for the email hostname in the open_connection function.
    Hope this helps someone.
    Trenton

    Hi;
    What is DB version?
    Please see:
    From Master Note For PL/SQL UTL_SMTP and UTL_MAIL Packages [ID 1137673.1] check Note 604763.1 "ORA-29278: SMTP transient error: 421 Service not available" When Using UTL_SMTP to Send Email.
    Regard
    Helios

  • UTL_SMTP Attachments

    1- How can i attach a text file, image file or other MS Office documents via UTL_SMTP package.
    2- How can i send CC or BCC through UTL_SMTP.

    Use UTL_MAIL for attachments.
    http://www.psoug.org/reference/utl_mail.html

  • Loading jar file.

    hi folks,
    i had a db function which holds - java stored procedure(is for sending email). while executing the function
    error says:
    Must issue a STARTTLS command first. regarding this error i followed this link
    http://stackoverflow.com/questions/386083/must-issue-a-starttls-command-first-sending-email-with-java-and-google-apps
    resoultion says in link
    I found the problem. Previously i was using j2ee.jar to import javax.mail.
    I removed j2ee.jar from the classpath and downloaded JavaMail 1.4.1 and put into my classpath two jars, smtp.jar and mailapi.jar. I use now smtps instead smtporacledb10gr2-windows7os
    so my question is where is j2ee.jar for removing?
    smtp.jar and mailapi.jar where put two of jar.
    so how load these jar? as resoultion says.

    If you think the sql or pl/sql code that executes your java-email routine then please post this pL/sql code. If you think the error is somewhere in java, then post it in a java forum.
    Note that in oracle databases the typical approach to send emails is (in this order)
    a) avoid it - it is a client atsk
    b) use utl_smtp or utl_mail (or sometimes apex_mail)
    c) use dbms_scheduler

  • Email sent...but attachment appears in body

    Hi,
    I am trying to send emails with attachments in pl/sql.
    I heard it can be done.
    I tried it, the code runs wiithout erros.
    But i cannot see the actual attachment.
    The content of the attachment appears in the body of the email.
    In the email i see this:
    This is an automated email. Please do not reply!
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary="-----AABCDEFBBCCC0123456789DE"
    This is a multi-part message in MIME format.
    -------AABCDEFBBCCC0123456789DE
    Content-Type: text/html;US-ASCII
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename="your_file_name.csv"
    SYS,ICOL$,TABLE,2009-06-19 15:35:34
    SYS,I_USER1,INDEX,2009-06-19 15:35:34
    SYS,CON$,TABLE,2009-06-19 15:35:34
    SYS,UNDO$,TABLE,2009-06-19 15:35:34
    SYS,C_COBJ#,CLUSTER,2009-06-19 15:35:34
    SYS,I_OBJ#,INDEX,2009-06-19 15:35:34
    SYS,PROXY_ROLE_DATA$,TABLE,2009-06-19 15:35:34
    SYS,I_IND1,INDEX,2009-06-19 15:35:34
    SYS,I_CDEF2,INDEX,2009-06-19 15:35:34
    SYS,I_PROXY_ROLE_DATA$_1,INDEX,2009-06-19 15:35:34
    SYS,FILE$,TABLE,2009-06-19 15:35:34
    SYS,UET$,TABLE,2009-06-19 15:35:34
    SYS,I_FILE#_BLOCK#,INDEX,2009-06-19 15:35:34
    SYS,I_FILE1,INDEX,2009-06-19 15:35:34
    SYS,I_CON1,INDEX,2009-06-19 15:35:34
    SYS,I_OBJ3,INDEX,2009-06-19 15:35:34
    SYS,I_TS#,INDEX,2009-06-19 15:35:34
    SYS,I_CDEF4,INDEX,2009-06-19 15:35:34
    SYS,IND$,TABLE,2009-06-19 15:35:34
    -------AABCDEFBBCCC0123456789DE--
    The part between the boundry
    (-------AABCDEFBBCCC0123456789DE--) should come as an attachment.
    Code for attachment:
    PROCEDURE R040_attach
    IS
    v_clob clob := empty_clob();
    c_mime_boundary VARCHAR2(256) := '-----AABCDEFBBCCC0123456789DE';
    v_len INTEGER;
    v_index INTEGER;
    BEGIN
    FOR x IN (SELECT *
    FROM all_objects
    WHERE ROWNUM < 20)
    LOOP
    v_clob :=
    v_clob
    || x.owner
    || ','
    || x.object_name
    || ','
    || x.object_type
    || ','
    || TO_CHAR(x.created, 'yyyy-mm-dd hh24:mi:ss')
    || UTL_TCP.crlf;
    END LOOP;
    UTL_SMTP.write_data(c, 'MIME-Version: 1.0' || UTL_TCP.crlf);
    UTL_SMTP.write_data(
    c,
    'Content-Type: multipart/mixed; boundary="' || c_mime_boundary || '"' || UTL_TCP.crlf
    UTL_SMTP.write_data(c, UTL_TCP.crlf);
    UTL_SMTP.write_data(
    c,
    'This is a multi-part message in MIME format.' || UTL_TCP.crlf
    UTL_SMTP.write_data(c, '--' || c_mime_boundary || UTL_TCP.crlf);
    --UTL_SMTP.write_data(c, 'Content-Type: text/html;US-ASCII' || UTL_TCP.crlf);
    --Content-Type: image/jpeg
    UTL_SMTP.write_data(
    c,
    'Content-Type: text/html;US-ASCII'
    || UTL_TCP.crlf
    || 'Content-Transfer-Encoding: base64'
    || UTL_TCP.crlf
    -- Set up attachment header
    UTL_SMTP.write_data(
    c,
    'Content-Disposition: attachment; filename="'
    || 'your_file_name.csv'
    || '"'
    || UTL_TCP.crlf
    UTL_SMTP.write_data(c, UTL_TCP.crlf);
    -- Write attachment contents
    v_len := DBMS_LOB.getlength(v_clob);
    v_index := 1;
    WHILE v_index <= v_len
    LOOP
    UTL_SMTP.write_data(c, DBMS_LOB.SUBSTR(v_clob, 32000, v_index));
    v_index := v_index + 32000;
    END LOOP;
    -- End attachment
    UTL_SMTP.write_data(c, UTL_TCP.crlf);
    UTL_SMTP.write_data(c, '--' || c_mime_boundary || '--' || UTL_TCP.crlf);
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR( -20110, 'Dwx0110 - R030 - ' || SQLERRM );
    END R040_attach;
    Any help would be appreciated.
    Thank you.

    Hi,
    there are some threads you may find interesting:
    UTL_SMTP mail with attachment( Problem in attaching zip file)
    UTL_SMTP or UTL_MAIL
    Regards.
    Al

  • How to send a main when i press a botton

    Oracle Forms 6i
    Hai All
    I am working in leave entry application. So when the user fill the form and when he press the button i need to send a mail to the corresponding boss. The user enter the mailid in the text field in the form.
    Pls tell me the steps to do this
    Thanks In Advance
    Srikkanth.M

    You can do this in a couple of ways; through the database using UTL_SMTP or UTL_MAIL, via OLE to a Mail Client on the users computer (uses WebUtil), or through the use of a Java Bean or Pluggable Java Component (PJC). My personal preference is through the database as this method is not dependent on external programs.
    Check out the Sending email from the database with UTL_SMTP package example and source code. This maildemo package does not include the ability to add attachements to the email sent from the database, but I was able to easily modify the demomail package to add this ability. Make sure you modify the package to use your email server or it will not work.
    Hope this helps,
    Craig B-)
    If a response is helpful or correct, please mark it accordingly.

  • How to generate an email on a database event?

    Dear gurus...I've heard about diferent ways of generating email in response to a database event e.g
    1 - Using UTL_MAIL package
    or
    2 - Event Driven Reporting feature of 10g Database and using SRW.Run_Report package to generate and mail a report.
    Now I'm confused that how should I accomplish the following tasks:
    (i) - How to generate an email after Insert/Update/Delete on a table and acknowledge the concerned users about that event?
    (ii) - How to attach a text file with that email?

    Dear Ivan...I've tried both UTL_SMTP and UTL_MAIL, UTL_SMTP is working well and sending mails but following code of UTL_MAIL is giving the error which I can't guess, why?
    DECLARE
    CRLF CHAR(2) := CHR(10) || CHR(13);
    BEGIN
    UTL_MAIL.SEND(sender => '[email protected]',
    recipients => '[email protected]',
    cc => NULL,
    bcc => NULL,
    subject => 'Test Email',
    message => 'Test line1' || CRLF || CRLF || 'Test line2',
    mime_type => 'text/plain; charset=us-ascii',
    priority => 1);
    END;
    and the error is:
    ORA-29279: SMTP permanent error: 554 Message is not RFC compliant
    ORA-06512: at "SYS.UTL_SMTP", line 20
    ORA-06512: at "SYS.UTL_SMTP", line 98
    ORA-06512: at "SYS.UTL_SMTP", line 345
    ORA-06512: at "SYS.UTL_MAIL", line 577
    ORA-06512: at "SYS.UTL_MAIL", line 594
    ORA-06512: at line 4
    could u guess why this error is generating???
    P.S...I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production on MS-Windows Server-2003.

  • Mail Error: ORA-29278: SMTP transient error: 421 Service not available

    I write process to send mail, it is running ok, but I have error ORA-29278: SMTP transient error: 421 Service not available.
    SMTP Host Address : localhost
    SMTP Host Port : 25
    When I connect to database as SYS and run : exec apex_mail.push_queue result is :
    Pushing email: 1225814842675154
    Pushed email: 1225814842675154
    PL/SQL procedure successfully completed.
    Please explain me what is happened!

    Hi;
    What is DB version?
    Please see:
    From Master Note For PL/SQL UTL_SMTP and UTL_MAIL Packages [ID 1137673.1] check Note 604763.1 "ORA-29278: SMTP transient error: 421 Service not available" When Using UTL_SMTP to Send Email.
    Regard
    Helios

  • How to send BLOB in attachement in oracle 10g?

    Hi,
    Actuall we requried to send and email from Oracle 10g database having attachements big in size aprox 10 to 30 MB.
    Is there any Custom Procedure or standard procedure for this.
    We are using UTL_SMTP and UTL_MAIL (Only support RAW attachement upto 32 k in size).
    Regards

    Hello,
    using UTL_SMTP and UTL_MAILI think It's difficult.
    But you can use DBMS_SCHEDULER, And DBMS_SCHEDULER is able to run OS command.
    So You might be able to send email with attachment via postfix etc...
    Although it might not have the solution for your req.
    Regards,

  • Bulk email from the database

    Good morning,
    Running Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production... (we'll be upgrading to 11g soon, but for now, stuck with 9i)
    Our clients have requested an email subscription service to be implemented for our news web site. The anticipated load will be:
    one module to support the following:
    - 3000 emails, with up to 50 instant email notifications an hour... so 150,000 emails delivered per hour. Email is sent as soon as new article is posted. (articles are embargoed and go live once embargo has passed)
    The other module is a open subscription form with double opt-in for the general public... with choices of instant email notification, daily digest or weekly digest or news article postings. the anticipated load is difficult to estimate for this one, but we could expect 50,000+ subscriptions... with up to 500 article posting per day. end users will have the ability to customize their subscription based on audience, department etc...
    In summary, we're looking to implement a solution that can deliver hundred of thousands of emails a day.
    As an Oracle developer, I always look first to the DB for solution. I know in 10g and up, utl_mail is available... not so in 9i. I do have a sample mail package from OTN that seems to do the trick. Emails will need to be sent as HTML, since they will contain a small image reference.
    Some potential ideas I have considered so far:
    for instant email notifications:
    - setting up queue tables and DBMS_JOB to monitor every minute and send email out to recipients using PL/SQL mail procedure
    - using Oracle AQ to manage queues, publish the payload with complete article information, subscriber will dequeue messages and send out using same PL/SQL email procedure. Messages in the queue will have delay set to article embargo date, to ensure articles are not emailed ahead of publishing.
    I have never worked with Oracle AQ before, but it seems to offer some benefits and more intelligence than a custom solution. I have also considered setting up a new Oracle instance for sending out emails, to offload some of the work from the main instance feeding the news web site.
    the daily and weekly digest emails are not as big a concern at this point, since they will be processed during off-peak hours, and will run once day/week... the Oracle AQ solution I thought would be an elegant and scalable solution for the instant notifications...
    My major concern at this point is scalibility and performance... I will rely on bulk processing in SQL to collect data... looping through the arrays to send out emails, as well as building up the email objects and sending them out in time is a concern.
    Given the potential volume we'll be dealing with, is a solution in Oracle the proper way to go? Our organization don't have an enterprise solution to this of course, so we have to build it from scratch. Other environments/tools at our disposal, Oracle 10g (10.1.3) application servers running Java ... could use JavaMail... our current set-up is 2 load-balanced application servers, with multiple OC4J containers running on each.
    Thanks for any tips or advice you may have.
    Stephane

    Bill... thank you for taking the time to respond in such a detailed manner. This is greatly appreciated. I have passed this along to our DBAs and messaging experts for review.
    I'm tasked with modeling the DB and optimizing it so it can achieve the target performance levels.
    Billy  Verreynne  wrote:
    Each SMTP conversation (from UTL_SMTP or UTL_MAIL) requires a socket handle. This is a server resource that needs to be allocated. The o/s has limits on the number of server resources a single process can use and that a single o/s account can use. Does not help that you have a scalable design, scalable code, and the server cannot supply the resources required to scale. So server capability and config are quite important.We've gotten our Unix specialists to look into this... we've been told our current platform is limited, and no further upgrades will be allocated, since we'll be moving to a newer platform in the "near future".
    There's also the physical network itself - as that 100,000 mails will each have a specific size and needs to be transported from the client (Oracle db server) to the server (mail/smtp server). The network must have the capacity and b/w to support this in addition to the current loads it is handling.Our network analysts will be putting us on a segregated network (subnet) to avoid impacting the rest of the organization... although bandwitdh is shared at the end of the day, we'll be somewhat isolated, with perhaps even our own firewalls and load balancers.
    You will need to look at a couple of things to decide on how to put all of this together. How are e-mails created in the database? Can they be immediately transmitted after being committed? Is the actual Mime body of the e-mail created by the transaction, or it is normal row and column data that afterward needs to be converted into a Mime body for mailing?The scheduling of emails are tricky.... articles are sometimes posted (comitted to the DB), but still under embargo... we plan to use this embargo date (date on which article goes live/public) as the "delay" in the job scheduling. At that point, article is emailed to thousands.
    For instant notifications, all recipients get the same content, article content direct in email. There custom pieces to include, eg unsubscribe link with unique identifier, edit subscription etc... but these bits could be pre-generated and stored with the email subscriber info, and appended to the mail body. No images or other binary files are embedded or attached... so we're dealing with mostly text/html in the body.
    Scalability is a direct function of design. So you will need to design each component for scalability. For example, do you create the Mime body dynamically as part of the e-mail transmission code unit? Or do you have a separate code unit that creates and persists Mime bodies that then are transmitted by the transmission code unit? Instant notification html email composition is a bit simpler. It gets tricky with daily, weekly, monthly digests. Here we have to assemble thousands of custom email bodies, based on subscription options (up to 5 custom fields, to configure subscription content)... from there assemble each individual mail body based on current subscriber options, then send the email.
    Mail bodies are potentially different for each individual subscriber, given the various permutations of selections, so really don't see how a body can be persisted for re-use when emailing, each may be single use only. In this case, looking at assembling thousands of emails, then emailing each one in a loop.
    Do you for example queue a single DBMS_JOB per e-mail? There are overheads in starting a job. So do you pay this overhead per mail, or do you schedule a job to transmit a 100 e-mails and pay this overhead once per 100 mails?for instant notifications, we'd be queuing a job for every article posted. From there, every email subscribed to instant notifications, and matching their subscription configuration to the article, will be retrieved and email sent.
    So there are a number of factors to consider ito design, how to deal with Mime bodies, how to deal with exception processing, how to parallelise processing and so on. One factor will need to be on how to deal with catchup processing - as there will be a failure of some sorts at a stage that means processing is some hours behind. And this needs to be factored into the design.An email job that fails half-way through concerns us... how do we proceed where we left off etc... may have to keep track of job numbers etc...
    The other option we're considering, is clustered Oracle 10gR3 application servers... to process and send the emails, using JavaMail... there is still an issue with Oracle handling the query volume required to assemble the customized emails for each subscriber (which could reach 50,000 within a year or two)...
    I would not select that as an architecture. This moves the data and application away from one another - into different process boundaries and even across hardware boundaries.
    When using PL/SQL, both data processing (SQL layer) and conditional processing and logic (PL layer) are integrated into a single server process. There is no faster way or more scalable way of combining code and data in Oracle. It does not matter how capable that Java platform/architecture is. For that Java code to get SQL data means shipping that data across a JDBC connection (and potentially between servers and across network infrastructure).
    In PL/SQL, it means a simple context switch from PL to SQL to fetch the data.. and even that we consider "slow" and mitigate using bulk processing in PL/SQL in order to decrease context switching.
    The fact the the data path for a Java app layer is a lot longer than for PL/SQL, automatically means that Java will be slower.totally agree with this. We're having a meeting this morning with all parties to review and discuss the points you have raised, and see if the required resources can be allocated on the Unix side to accommodate the potential load.
    >
    I'm looking at leveraging materialized views (to pre-assemble content), parallelism (query and procedural), Advanced Queuing (seems complex)... AQ is not that complex.. and perhaps not needed. You will however need a form of parallelism in order to run a number of e-mail transmission processes in parallel. The question is how do you tell each unique process what e-mails to transmit, without causing serialisation between parallel processes?
    This can be home rolled parallelism as shown in {message:id=1534900} (from a technique posted by Tom on asktom that is now a 11.2 feature). You can also use parallel pipelined tables. Or use AQ. I'm pretty sure that a solid design will support any of these - modularising the parallel processing portion of it and allowing different methods to be used to test drive and even benchmark the parallel processing component.
    If using AQ, we're considering a separate Oracle instance in a different AIX partition perhaps, which could manage the email function. Our main instance (which feeds our public web site, and stores all data), would push objects onto the queue, and items would be dequeued on the other end in the other Oracle instance.
    It however sounds like a very interesting project. Crunching lots of data and dealing with high processing demands... that is the software engineer's definition of fun. :-)Indeed... I wouldn't consider myself as a software engineer at this point, but perhaps after this is done, I'll have earned my stripes. ;-)
    Edited by: pl_sequel on Jul 13, 2010 9:57 AM

  • Revoking sys.utl_smpt  from PUBLIC

    Oracle 10.2. We have ASP application on the top.
    I granted sys.utl_smpt to ST schema/user
    Then I revoke sys.utl_smpt FROM PUBLIC. This caused 5 invalid objects: sys.utl_smtp, sys.utl_mail, sys.dbms_aqelm, st.mail_files, st.mail_pkg. After re-compiled, two ST objects are still not valid: mail_files, mail_pkg. The error message is UTL_SMTP must be declared.
    The line is Mail_files procedure causing this problem: conn utl_smpt.connection
    I granted sys.utl_smpt specificly to this user and this user's procedure is still having problem. What am I doing wrong?
    Thanks
    S.

    After re-compiled, two ST objects are still not valid: mail_files, mail_pkg. The error message is UTL_SMTP must be declared.
    I granted sys.utl_smpt specificly to this user and this user's procedure is still having problemWhat Grant did you execute ?
    What is the "problem" that you are still having ?
    Hemant K Chitale

Maybe you are looking for

  • Error ocurred during initialization of VM. Unable to load native library...

    Hi, I´m trying to install Oracle 9i on a PC with Suse 9.2. when I put the first CD it comes with this error: Initializing Java Virtual Machine from /tmp/OraInstall2006-05-04_11-13-11PM/jre/bin/java. Please wait... Error occurred during initialization

  • Issues with Denim update; Lumia 822

    Good Day, I have installed the newly available Denim update for my Lumia 822. But not without some glitches. If anyone can help me out, I'd sure appreciate it! Problems (by #): 1. The pictures/photos tile no longer works. It just bounces back to that

  • Multiple connector instances

    Hello,           how can I access multiple instances of an EIS? Is it possible to deploy more than one instances of a resource adapter? If so, how should I deploy those resource adapter instances. Thanks in advance.           

  • SOS beginner needs XSLT help

    Hello, I have an XML document that does not have any space between brackets as follows: <?xml version="1.0" encoding="UTF-8"?> <root><One><a>toto</a><a>titi</a></One><One><a>tata</a><a>tutu</a></One></root>I have been looking for an XSLT script that

  • Calling Unix command from the plsql

    Hi , I am executing java code from the UNIX Shell script. Before executing this command i want to write plsql code to and pass the files to java command. In the plsql code i want to select request id's using the cursor and find the .out files for eac