Sending mail from oracle procedure

Hi Experts,
I want to send mail from oracle Procedure. Anybody please help me out.
Thanks.

BEGIN
UTL_MAIL.send(sender => '[email protected]',
recipients => '[email protected],[email protected]',
cc => '[email protected]',
bcc => '[email protected]',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!');END;

Similar Messages

  • How send mail from Oracle stored procedure?

    Hi,
    I need send mail using Oracle stored procedure. Can anybody helpme with any recomendation about that, sample code or so?.
    [email protected]
    null

    Hi Raul Martinez
    utl_smtp package is available since oracle 8.1.6.
    If U have a older version then U can not.
    Thank U.
    edwin

  • Send mail from oracle database 10g

    Hi ,
    I need to send a test mail from oracle database 10g to my gmail account through a stored procedure .
    I will pass the list of recipents , subject and text of the mail through parameters .
    Can anyone give me the code of the storerd procedure please ,
    Thank you .

    hi, for example
    DECLARE
    mail_conn UTL_SMTP.connection;
    smtp_relay VARCHAR2(32) := '172.16.x.x';
    recipient_address VARCHAR2(64) := '[email protected]';
    sender_address VARCHAR2(64) := '[email protected]';
    mail_port NUMBER := 25;
    msg VARCHAR2(200);
    BEGIN
    mail_conn := UTL_SMTP.open_connection(smtp_relay,mail_port);
    UTL_SMTP.HELO(mail_conn, smtp_relay);
    UTL_SMTP.MAIL(mail_conn, sender_address);
    UTL_SMTP.RCPT(mail_conn, recipient_address);
    UTL_SMTP.DATA(mail_conn, 'Payment request iniated');
    UTL_SMTP.QUIT(mail_conn);
    end;

  • How to send mails from Oracle database

    Hi All,
    I want to send a mail from my oracle database once my store
    procedure runs successfully or fails.
    How can i do this.
    what are the preliminary modules of Oracle which need to be
    active for me to do so.
    If any once can also mention about any links that give
    information about the same it will be very helpful for me.
    Thanks and Regards
    Srinivas Chebolu

    CREATE OR REPLACE PROCEDURE SEND_MAIL_TCP(
    msg_from varchar2 := '[email protected]',
    msg_to varchar2,
    msg_subject varchar2 := 'E-Mail message from your database',
    msg_text varchar2 := '' )
    IS
    c utl_tcp.connection;
    rc integer;
    BEGIN
    c := utl_tcp.open_connection('1.17.0.218', 25); -- open the SMTP
    port 25 on local machine
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'HELO localhost');
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
    rc := utl_tcp.write_line(c, '');
    rc := utl_tcp.write_line(c, msg_text);
    rc := utl_tcp.write_line(c, '.'); -- End of message body
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'QUIT');
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    utl_tcp.close_connection(c); -- Close the connection
    EXCEPTION
    when others then
    raise_application_error(-20000,'Unable to send e-mail message
    from pl/sql');
    END;
    show errors
    exec send_mail(msg_to =>'[email protected]');
    exec send_mail(msg_to
    =>[email protected]',msg_text=>'Look Yaar, I can send
    mail from plsql');

  • Sending Mail from Oracle forms or reports

    Hi
    I have to send mail from forms or reports . Is there any way or builtin to do this.
    If anybody have experience in this please give the
    detailed example on this.
    Regards
    Arun

    Look at http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt
    It creates a package in the database for sending mail.
    If you want to send mail from the local machine using Outlook, you'll have to use OLE, but it's not something I've tried.

  • How send mail from stored procedure

    How to send a mail from a PL/SQL procedure.I am Writing a Batch program and if the program fails to due to data errors mail needs to be sent to the users indicating that the process is failed.Can anyone please point to any resources.Thanks

    How to send a mail from a PL/SQL procedure.I am Writing a Batch program and if the program fails to due to data errors mail needs to be sent to the users indicating that the process is failed.Can anyone please point to any resources.
    Create this procedure in your database:
    PROCEDURE test_mail
    (sender IN VARCHAR2,
    recipient IN VARCHAR2,
    subj IN VARCHAR2,
    body IN VARCHAR2)
    IS
    crlf VARCHAR2(2):= CHR( 13 ) || CHR( 10 );
    mesg VARCHAR2(4000);
    mail_conn UTL_SMTP.CONNECTION;
    BEGIN
    mail_conn := utl_smtp.open_connection('mailhost', 25);
    utl_smtp.helo(mail_conn, 'mailhost');
    utl_smtp.mail(mail_conn, sender);
    utl_smtp.rcpt(mail_conn, recipient);
    mesg:= 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
    'From: ' || sender || crlf ||
    'To: ' || recipient || crlf ||
    'Subject: ' || subj || crlf;
    mesg:= mesg || '' || crlf || body;
    utl_smtp.data(mail_conn, mesg);
    utl_smtp.quit(mail_conn);
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(sqlerrm);
    END;
    Let me know in case of any concerns..
    Chow
    Peyush

  • ORA-29279: SMTP permanent error: To Send Mail from Oracle 10g (10.2.0.1)

    I have installed Oracle 10g (10.2.0.1) on Windows XP (SP2) machine at my home PC.There is a broadband connection on my home PC.I have installed UTL_MAIL package and then set SMTP_OUT_PARAMETER by the following SQL Statement.
    My machine IP address is 192.168.0.3
    SQl> alter system set smtp_out_server = 'smtp.bsnl.in:25' scope = 25;
    Then we run the following script.
    BEGIN
    UTL_MAIL.SEND(
    SENDER => '[email protected]',
    RECIPIENTS => '[email protected]',
    SUBJECT => 'Testing UTL_MAIL',
    MESSAGE => 'The receipt of this email means'||
    'that it works for UTL_MAIL'
    END;
    Then following error message comes.
    BEGIN
    ERROR at line 1:
    ORA-29279: SMTP permanent error: 553 Authentication is required to send mail as
    <[email protected]>
    ORA-06512: at "SYS.UTL_SMTP", line 21
    ORA-06512: at "SYS.UTL_SMTP", line 99
    ORA-06512: at "SYS.UTL_SMTP", line 222
    ORA-06512: at "SYS.UTL_MAIL", line 407
    ORA-06512: at "SYS.UTL_MAIL", line 594
    ORA-06512: at line 2
    Can anybody suggest the solution of the above problem.

    Hi,
    is your smtp server configured to use anonymous connection?
    Attackwave
    Reply Code       Description
    211      System status, or system help reply
    214      Help message [Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user]
    220      <domain> Service ready
    221      <domain> Service closing transmission channel
    250      Requested mail action okay, completed
    251      User not local; will forward to <forward-path>
    252      OK, pending messages for node <node> started. Cannot VRFY user (for example, info is not local), but will take message for this user and attempt delivery.
    253      OK, <messages> pending messages for node <node> started
    354      Start mail input; end with <CRLF>.<CRLF>
    355      Octet-offset is the transaction offset
    421      <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down.)
    450      Requested mail action not taken: mailbox unavailable [for example, mailbox busy]
    451      Requested action terminated: local error in processing
    452      Requested action not taken: insufficient system storage
    453      You have no mail.
    454      TLS not available due to temporary reason. Encryption required for requested authentication mechanism.
    458      Unable to queue messages for node <node>
    459      Node <node> not allowed: reason
    500      Syntax error, command unrecognized (This may include errors such as command line too long.)
    501      Syntax error in parameters or arguments
    502      Command not implemented
    503      Bad sequence of commands
    504      Command parameter not implemented
    521      <Machine> does not accept mail.
    530      Must issue a STARTTLS command first. Encryption required for requested authentication.
    534      Authentication mechanism is too weak.
    538      Encryption required for requested authentication mechanism.
    550      Requested action not taken: mailbox unavailable [for , mailbox not found, no access]
    551      User not local; please try <forward-path>
    552      Requested mail action terminated: exceeded storage allocation
    *553      Requested action not taken: mailbox name not allowed [for example, mailbox syntax incorrect]*
    554      Transaction failed

  • Sending mail from oracle porcedures?

    Hi All,
    i am using personal oracle 8 is it possible to send a mail to a internet mail address?
    by using UTL SMTP packages ? if possible can anybody give me the procedures code ?
    Thanks in advance
    Reddy

    Tom Kyte has a number of rather extensive discussions on utl_smtp on his web site http://asktom.oracle.com. Here is one such thread http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:255615160805
    That should provide all the code you would want. The only wrinkle is that you need to ensure that there is an SMTP server available that your database can connect to. Free email services like Hotmail and Yahoo generally don't have SMTP servers and many companies run Exchange and don't provide internally visible SMTP servers.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Sending mail from oracle

    Dear Expert's,
    When am executing this block, there are no any error. but mail can't received.
    So, please give me solution.
    DECLARE
    mailhost VARCHAR2 (64) := '000.000.000.000'; --SMTP Server IP (smtp port is 25)
    sender VARCHAR2 (64) := '[email protected]';
    recipient VARCHAR2 (64) := '[email protected]';
    mail_conn UTL_SMTP.connection;
    BEGIN
    mail_conn := UTL_SMTP.open_connection (mailhost, 25);
    UTL_SMTP.helo (mail_conn, mailhost);
    UTL_SMTP.mail (mail_conn, sender);
    UTL_SMTP.rcpt (mail_conn, recipient);
    UTL_SMTP.open_data (mail_conn);
    UTL_SMTP.write_data (mail_conn, 'This is a test message.' || CHR (13));
    UTL_SMTP.write_data (mail_conn, 'This is line 2.' || CHR (13));
    UTL_SMTP.close_data (mail_conn);
    UTL_SMTP.quit (mail_conn);
    END;
    Edited by: Viveka Nand on Nov 17, 2011 2:35 AM

    Hi Vivek,
    Oracle 11g can support utl_mail package. But I don't know whether your organization is installed in server or not.
    If not please raise a request to your DBA and Installed it. Then you can use utl_mail package. While using this package, please note the following things.
    rerequisites:
    I need to execute these two scripts as sysdba;
    @$ORACLE_HOME/rdbms/admin/utlmail.sql;
    @$ORACLE_HOME/rdbms/admin/prvtmail.plb;
    Then I have to configure smtp server information in init.ora file . or spfile.
    smtp_out_server = 43.88.67.14:25
    Then execute this commond as sysdba;
    alter system set smtp_out_server = '43.88.67.14:25' scope=both;
    exec utl_mail.send(sender => '[email protected]',
    recipients => '[email protected]','[email protected]',
    subject => 'Testing Mail',
    message => 'Hi..This is a test mail');
    grant execute permission on UTL_MAIL package.
    eg: grant execute on utl_mail to <schema>;
    Note: you can't send to Gmail..yahoo..etc...This is with in your org.

  • How a send a mail from  Oracle   ----- urgent

    Hi,
    I am working in oracle9i and linux 2.4. i need to a send mail from oracle .Please send the procedure to me in a detail manner.
    I am having one procedure .plz check and change if possible...
    declare
    l_maicon utl_smtp.connection;
    begin
    l_maicon :=utl_smtp.open_connection('mail.com');
    utl_smtp.helo(l_maicon,'mail.com');
    utl_smtp.mail(l_maicon,'[email protected]');
    utl_smtp.rcpt(l_maicon,'[email protected]');
    utl_smtp.data(l_maicon,'From: [email protected]' || utl_tcp.crlf||
    'To: [email protected]' || utl_tcp.crlf ||
    'Subject: database e-mail option' || utl_tcp.crlf ||
    'You have received this mail from database!');
    utl_smtp.quit(l_maicon);
    end;
    Please explain me in detail
    Gobi....

    If I do a Google search on the terms "Oracle mail", this askTom thread is the second hit
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:255615160805
    Did you already find this thread? If so, did it not answer your question sufficiently?
    Additionally, it would be quite helpful if you would post the results of running the code you posted. You've given no indication whether there is an error, what error might be generated, whether you're not seeing the expected behavior, whether the code crashes your system, etc. That leaves us to guess about what problems you might have between syntax errors, permission problems, configuration problems on the database, configuration problems on the SMTP server, operating system problems, network problems (the list goes on).
    Justin

  • Sending mail in Oracle 8i

    Hi,
    I am trying to send an email in Oracle 8i Personnel edition, but have encountered problems with the UTL_SMTP package. I have a stored procedure to send mail, but when I run this procedure, I get the following error messages:
    ORA-20001: 421 Service not available
    ORA-06512: at "SYSTEM.UTL_SMTP", line 83
    ORA-06512: at "SYSTEM.UTL_SMTP", line 121
    ORA-06512: at "SYSTEM.DEMO_MAIL", line 257
    ORA-06512: at "SYSTEM.DEMO_MAIL", line 118
    ORA-06512: at "SYSTEM.DEMO_MAIL", line 104
    ORA-06512: at line 2.
    Can anyone help??

    If you can't access the utl_smtp package (you can also look from Oracle Developper by opening the Database node followed by the SYS node which will list the database packages), here is a quick example using OLE2:
    DECLARE
    objOutlook OLE2.OBJ_TYPE;
    objArg OLE2.LIST_TYPE;
    objMail OLE2.OBJ_TYPE;
    BEGIN
    objOutlook := OLE2.CREATE_OBJ('Outlook.Application');
    objarg := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(objarg,0);
    objMail := OLE2.INVOKE_OBJ(objOutlook,'CreateItem',objarg);
    OLE2.DESTROY_ARGLIST(objarg);
    OLE2.SET_PROPERTY(objmail,'To','<emailaddress>');
    OLE2.SET_PROPERTY(objmail,'Subject','Test email from Oracle Forms');
    OLE2.SET_PROPERTY(objmail,'Body','This is a test sending mail from Oracle forms');
    OLE2.INVOKE(objmail,'Display');  to display before sending
    OLE2.INVOKE(objmail,'Send');
    OLE2.RELEASE_OBJ(objmail);
    OLE2.RELEASE_OBJ(objOutlook);
    END;

  • Problem in sending mail from database with attachment

    Hi All,
    I amd using forms10g,oracle10g
    I am facing a error while running a procedure to send mail from db
    procedure is:
    declare
    ErrorMessage VARCHAR2(4000);
    ErrorStatus NUMBER;
    -- enable SQL*PLUS output;
    --SET SERVEROUTPUT ON
    -- redirect java output into SQL*PLUS buffer;
    --exec dbms_java.set_output(5000);
    BEGIN
    ErrorStatus := SendMailJPkg.SendMail(
    SMTPServerName => '192.168.4.2',
    Sender => '[email protected]',
    Recipient => '[email protected]',
    CcRecipient => '',
    BccRecipient => '',
    Subject => 'hth106: Test JavaMail',
    Body => 'This is the body: Hello, this is a test that spans 2 lines',
    AuthReqdYNNum => 1,
    UserID => 'jagan',
    Password => 'songbirds',
    ErrorMessage => ErrorMessage,
    Attachments => SendMailJPkg.ATTACHMENTS_LIST('C:\oramail\MHTHSO_GEN45.html')
    END;
    while running this procedure i am receiving following error
    "ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.IncompatibleClassChangeError"
    but the same procedure sending mail from all other user in the same database
    I am very myuch confused.i have given the all rights
    below mentioned rights are given .it is working in all other user on the same db except this user "hth106". And all the othere things are compared between working user and this hth106 user every things are same.But i am receiving error when i sending mail with attachment if the mail is sending without attachement it is working fine
    below rights are given to this user
    1.exec dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','read');
    2.exec dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','write');
    3.exec dbms_java.grant_permission('HTH106','java.net.SocketPermission','*','connect');
    4.exec dbms_java.grant_permission('HTH106','java.net.SocketPermission','*','resolve');
    5.exec dbms_java.grant_permission('HTH106','java.io.FilePermission','C:\oramail\*','read');
    exec dbms_java.grant_permission('HTH106','java.io.FilePermission','C:\oramail\*','write');
    6.call dbms_java.grant_permission('HTH106','java.net.SocketPermission','HTHDS01','resolve');
    7.call dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','read,write');
    7.call dbms_java.grant_permission('HTH106', 'java.io.FilePermission','C:\oramail\*','read');
    please advise me to proceed further
    Thanks in advance
    Thanks ,
    Antony

    With respects to the following:
    The bit you'll have most diffulty with is the attachment, because you can't be sure that
    the directory path specified is one that the database can read from. You can probably
    resolve this by using some java to move the file to a directory which utl_file can see.Another alternative is to specify a location on then database server where all file attachments MUST be copied to and the define and Oracle DIRECTORY (CREATE OR REPLACE DIRECTORY [dir_name] AS '/dir/name/on/files/system';) that references this location. When you attach a file to an email, then you only have to refer to the DIRECTORY for the file location.
    Just my 2 cents on the topic. :-)
    Craig...

  • Urgent - Mail from Oracle

    Dear friends,
    I want 2 send mail from Oracle PL/SQL . I have used the
    following code to send mail.
    create or replace PROCEDURE send_mail_1 (sender IN VARCHAR2,
    recipient IN VARCHAR2,
    message IN VARCHAR2)
    IS
    mailhost VARCHAR2(30) := 'mailhost.mydomain.com';
    smtp_error EXCEPTION;
    mail_conn utl_tcp.connection;
    PROCEDURE smtp_command(command IN VARCHAR2,
    ok IN VARCHAR2 DEFAULT '250')
    IS
    response varchar2(3);
    x number;
    BEGIN
    x:= utl_tcp.write_line(mail_conn, command);
    response := substr(utl_tcp.get_line(mail_conn), 1, 3);
    IF (response <> ok) THEN
    RAISE smtp_error;
    END IF;
    END;
    BEGIN
    mail_conn := utl_tcp.open_connection(mailhost, 25);
    smtp_command('HELO ' || mailhost);
    smtp_command('MAIL FROM: ' || sender);
    smtp_command('RCPT TO: ' || recipient);
    smtp_command('DATA', '354');
    smtp_command(message);
    smtp_command('QUIT', '221');
    utl_tcp.close_connection(mail_conn);
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
    END;
    I am able to successfuly create the procedure. But while
    executing the procedure I got the following error "ORA-29540:
    class oracle/plsql/net/TCPConnection does not exist".
    I have used the following format while I tried executing the
    procedure
    execute send_mail_1
    ('[email protected]','[email protected]','Test')
    Are the above parameters are correct?. Further should I need to
    change 'mailhost.mydomain.com' string value?- If yes what value
    should be given there?
    mailhost VARCHAR2(30) := 'mailhost.mydomain.com';
    Kindly help me in this regards.
    Thanks in advance
    Narayanan

    Something like:
    Create or Replace  Procedure Send_Reminder IS
      CURSOR cur_reminders_needed IS
      SELECT *
      FROM mytable
      where trunc(reminder_date) = trunc(sysdate)
      FOR UPDATE OF reminder_date;
    BEGIN
      For rec in cur_reminders_needed LOOP
        my_mail_pkg.send_emal(rec.stuff_from_my_table);
        UPDATE mytable set reminder_date = reminder_date+rec.reminder_increment
        WHERE CURRENT OF cur_reminders_needed;
      END LOOP;
      COMMIT;
    END;Then use dbms_job.submit to create a job that runs send_reminders every day.
    Then take a nap, Oracle will do everything else.

  • Not able to send mail thru Oracle

    Hi all,
    I am using Oracle 9.2.0.6 on RHEL platform.....
    I am using the below procedure to send mail from oracle
    CREATE or REPLACE PROCEDURE SimpleTextMessage IS
        mailHOST    VARCHAR2(64) := '10.0.1.2';
        mailFROM    VARCHAR2(64);
        mailTO      VARCHAR2(64);
        mailCONN    utl_smtp.connection;
        mailDATE    VARCHAR2(20);
        vreply      utl_smtp.reply;
        vreplies    utl_smtp.replies;
        i           number;
    BEGIN
        mailFROM := '[email protected]';
        mailTO   := '[email protected]';
        SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;
          dbms_output.put_line('open_connection');
          dbms_output.put_line('---------------');
          vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
          dbms_output.put_line('help');
          dbms_output.put_line('----');
          vreplies := utl_smtp.help(mailCONN, 'HELP');
          for i in 1..vreplies.count loop
            dbms_output.put_line( 'code = ' || vreplies(i).code );
            dbms_output.put_line( 'text = ' || vreplies(i).text );
          end loop;
    vreply := utl_smtp.open_data(mailCONN);
          utl_smtp.write_data(mailCONN, 'Subject: '|| 'A subject' || chr(13));
          utl_smtp.write_data(mailCONN, 'From:    '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN, 'Date:    '||mailDATE     || chr(13));
          utl_smtp.write_data(mailCONN, 'To:      '||mailTO       || chr(13));
          utl_smtp.write_data(mailCONN, 'CC:      '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN, 'BCC:     '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN,                              chr(13));
          utl_smtp.write_data(mailCONN, 'Hello Friend.'           || chr(13));
          utl_smtp.write_data(mailCONN, 'Drop me an e-mail.'      || chr(13));
          dbms_output.put_line('close_data');
          dbms_output.put_line('----------');
          vreply := utl_smtp.close_data(mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
          dbms_output.put_line('quit');
          dbms_output.put_line('----');
          vreply := utl_smtp.quit(mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
    END;
    /At the time of compilation i am not getting any error but when i call that proc i am getting the below error:
    SQL> exec cadata3.simpletextmessage();
    BEGIN cadata3.simpletextmessage(); END;
    ERROR at line 1:
    ORA-29277: invalid SMTP operation
    ORA-06512: at "SYS.UTL_SMTP", line 43
    ORA-06512: at "SYS.UTL_SMTP", line 279
    ORA-06512: at "CADATA3.SIMPLETEXTMESSAGE", line 29
    ORA-06512: at line 1can asomebody throw some light on the same....

    Still getting the same problem
    CREATE or REPLACE PROCEDURE SimpleTextMessage IS
        mailHOST    VARCHAR2(64) := '10.0.1.2:8443';
        mailFROM    VARCHAR2(64);
        mailTO      VARCHAR2(64);
        mailCONN    utl_smtp.connection;
        mailDATE    VARCHAR2(20);
        vreply      utl_smtp.reply;
        vreplies    utl_smtp.replies;
        i           number;
    BEGIN
        mailFROM := '[email protected]';
        mailTO   := '[email protected]';
        SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;
          dbms_output.put_line('open_connection');
          dbms_output.put_line('---------------');
          vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
          dbms_output.put_line('help');
          dbms_output.put_line('----');
          vreplies := utl_smtp.help(mailCONN, 'HELP');
          for i in 1..vreplies.count loop
            dbms_output.put_line( 'code = ' || vreplies(i).code );
            dbms_output.put_line( 'text = ' || vreplies(i).text );
          end loop;
    vreply := utl_smtp.close_data(mailCONN);
          utl_smtp.write_data(mailCONN, 'Subject: '|| 'A subject' || chr(13));
          utl_smtp.write_data(mailCONN, 'From:    '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN, 'Date:    '||mailDATE     || chr(13));
          utl_smtp.write_data(mailCONN, 'To:      '||mailTO       || chr(13));
          utl_smtp.write_data(mailCONN, 'CC:      '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN, 'BCC:     '||mailFROM     || chr(13));
          utl_smtp.write_data(mailCONN,                              chr(13));
          utl_smtp.write_data(mailCONN, 'Hello Friend.'           || chr(13));
          utl_smtp.write_data(mailCONN, 'Drop me an e-mail.'      || chr(13));
          dbms_output.put_line('close_data');
          dbms_output.put_line('----------');
          vreply := utl_smtp.close_data(mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
          dbms_output.put_line('quit');
          dbms_output.put_line('----');
          vreply := utl_smtp.quit(mailCONN);
          dbms_output.put_line( 'code = ' || vreply.code );
          dbms_output.put_line( 'text = ' || vreply.text );
    END;
    /error
    SQL> exec cadata3.simpletextmessage();
    BEGIN cadata3.simpletextmessage(); END;
    ERROR at line 1:
    ORA-29277: invalid SMTP operation
    ORA-06512: at "SYS.UTL_SMTP", line 43
    ORA-06512: at "SYS.UTL_SMTP", line 303
    ORA-06512: at "CADATA3.SIMPLETEXTMESSAGE", line 28
    ORA-06512: at line 1Edited by: user00726 on Jul 31, 2009 4:14 AM

  • Send mail from database server to client

    Hi,
    i Want to send mails from oracle database (10gR1 on windows 2003) to user client systems (Developer 6i). Can anyone tell me how it is possible ?
    Thanks

    You can use utl_smtp to send mail or Java stored procedure to send the mail.
    example of utl_smtp.
    CREATE OR REPLACE PROCEDURE SEND_MAIL (
    msg_to varchar2,
    msg_subject varchar2,
    msg_text varchar2 )
    IS
    c utl_smtp.connection;
    rc integer;
    msg_from varchar2(50) := 'Oracle9.2';
    mailhost VARCHAR2(30) := '127.0.0.1'; -- local database host
    BEGIN
    c := utl_smtp.open_connection(mailhost, 25); -- SMTP on port 25
    utl_smtp.helo(c, mailhost);
    utl_smtp.mail(c, msg_from);
    utl_smtp.rcpt(c, msg_to);
    utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
    'To: ' || msg_to || utl_tcp.crlf ||
    'Subject: ' || msg_subject ||
    utl_tcp.crlf || msg_text);
    utl_smtp.quit(c);
    EXCEPTION
    WHEN UTL_SMTP.INVALID_OPERATION THEN
    dbms_output.put_line(' Invalid Operation in Mail attempt
    using UTL_SMTP.');
    WHEN UTL_SMTP.TRANSIENT_ERROR THEN
    dbms_output.put_line(' Temporary e-mail issue - try again');
    WHEN UTL_SMTP.PERMANENT_ERROR THEN
    dbms_output.put_line(' Permanent Error Encountered.');
    END;
    http://www.oracleutilities.com/Packages/utl_smtp.html

Maybe you are looking for

  • How to prepare to get good knowledge in SAP-CRM

    Hi Experts,                  I recently completed my MBA and i would like to start my career as a CRM functional consultant. Give me suggestions on how to prepare and how to get expertise in SAP CRM. THANK YOU.....

  • PSE 6

    I'm unable to install PSE 6 in my G5, MAC OS 10.5.8. ADOBE has told me that it was my computer, which after talking to APPLE there is no problems. What I get is the ICON, when clicked I get a folder with "bootstrapper.dmg"  When clicked I get a pictu

  • "undefined" MobibleMe Gallery widget

    I recently uploaded two galleries to MobileMe and tried to use the "MobileMe Gallery" widget in iWeb. For some reasons, both widgets show "undefined" as its title and the cover picture is all black. What's going on?? An illustration of the problem: h

  • Playback garbled

    When I try and watch Apple keynotes the video and audio playback are jumpy and garbled. Windows & Quicktime are fully up to date. I have tried uninstalling and reinstalling quicktime - no help. I can watch videos in iTunes no problems. My Internet co

  • SD 16:9 convert to HD

    Just wonder if there is possible to convert from SD 16:9 to HD format? How? convert service center?