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;

Similar Messages

  • 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 a mail from oracle database

    Hi,
    I have a requirement to send a mail from oracle database.I use UTL_TCP package for this.Although my procedure is executed successfully,i dont get the mails in my inbox.Please help me to figure out a solution.
    Thanks in advance....

    Hi, you must use UTL_SMTP package for send emails, it has more performance and features for debug. You must look the next code, this is a example for send emails.
    DECLARE
    c UTL_SMTP.CONNECTION;
    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
    END;
    BEGIN
    c := UTL_SMTP.OPEN_CONNECTION('smtp-server.acme.com');
    UTL_SMTP.HELO(c, 'foo.com');
    UTL_SMTP.MAIL(c, '[email protected]');
    UTL_SMTP.RCPT(c, '[email protected]');
    UTL_SMTP.OPEN_DATA(c);
    send_header('From', '"Sender" <[email protected]>');
    send_header('To', '"Recipient" <[email protected]>');
    send_header('Subject', 'Hello');
    UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || 'Hello, world!');
    UTL_SMTP.CLOSE_DATA(c);
    UTL_SMTP.QUIT(c);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    BEGIN
    UTL_SMTP.QUIT(c);
    EXCEPTION
    WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
    NULL; -- When the SMTP server is down or unavailable, we don't have
    -- a connection to the server. The QUIT call will raise an
    -- exception that we can ignore.
    END;
    raise_application_error(-20000,
    'Failed to send mail due to the following error: ' || sqlerrm);
    END;
    Also review the next link for get more information about the UTL_SMTP packege.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_smtp.htm#sthref15587
    Regards.

  • Send sms from oracle database/application server

    HI all
    I Wanted to send and recieve SMS not mails from oracle(database/application server).any possible solutions and what are the things that i required for that.i-e any service provider or any machine or somethings else.and secound thing can i use wirless server and what are the requirments for that

    Handle:      taimur
    Status Level:      Newbie
    Registered:      Aug 3, 2009
    Total Posts:      42
    Total Questions:      16 (16 unresolved)
    so many questions without ANY answers.
    http://forums.oracle.com/forums/ann.jspa?annID=718
    http://www.lmgtfy.com/?q=oracle+send+sms

  • Disconnected from Oracle Database 10g Release 10.2.0.1.0 - Production

    Can anyone tell me why my Database is not starting, I have been getting this error for quite some time now
    Total System Global Area 532676608 bytes
    Fixed Size          1249992 bytes
    Variable Size          167775544 bytes
    Database Buffers     360710144 bytes
    Redo Buffers          2940928 bytes
    Database mounted.
    Database opened.
    SQL> Disconnected from Oracle Database 10g Release 10.2.0.1.0 - Production
    Thank you in advance

    Your Database has started. It only disconnected the session that started the database. For instance, if you are using a startuo script or dbstart.
    Why do you think it is not started?

  • How to call web services from oracle database 10g

    Hi all ,
    How can i call web services from oracle database 10g ?
    thanks ...

    abdou123 wrote:
    but how can i get complex result
    for example
    i pass input parameter like National Id Number
    and get the person details ( name , age , date of birth , ............ ) .Basic approach to web services using UTL_HTTP explained in {message:id=10448611}.
    An example of using a pipeline table function as a data transformation process (turning web data into rows and columns) in {message:id=10158148}.

  • How to Send SMS from Oracle Database to Mobile

    Hi All,
    I need urgent help in how to send sms from oracle database to mobile
    thanks and best regards

    you can use smslib..... . i have made a program with this. its working fine with oracle database.
    see the links here ...
    http://halimdba.blogspot.com/2011/08/send-sms-from-oracle-database-with.html
    by the way, how you can say "urgent help" ?
    regards
    Halim

  • 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;

  • Database upgradation steps from Oracle Database 10g EE to 11g R2

    If any document/Steps available for the upgradation of database from Oracle Database 10g EE to 11g R2 please provide us.
    Thank you.

    Please refer to this document for a step by step guide:
    http://www.oracleflash.com/34/Upgrade-Oracle-10g-Release-2-to-Oracle-11g-Release-2.html

  • 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 to upgrade from oracle database 10g 10.1.0.3 to 10.1.0.5 or 10.2.0.4

    I have a oracle database 10g version 10.1.0.3 on solaris 10 x86. I can't find the recent patches suitable to my database.
    How can I upgrade it to 10.1.0.5 or higher (10.2.0.4)?
    Thanks.

    take a looks at this metalink doc for all upgrade needs...
    sub: Complete checklist for manual upgrades of Oracle databases from anyversion to any version on any platform (documents only from 7.3.x>>8.0.x>>8.1.x>>9.0.x>>9.2.x>>10.1.x>>10.2.x>>11.1.x)
    Doc ID:      421191.1

  • 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

  • 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

  • Data Transfer from Oracle database 10g to Oracle database 9i

    Hi Experts,
    We need to insert records at the speed of min 10,000 records per sec in the following condition.
    Source : Oracle 10 g and Oracle 9i
    We need to select the data from Oracle 10g and insert into Oracle 9i database.
    Here we not allowing to create database link and also not allowing to create view or materialized view
    because this two database is not on same network.
    So we developing the small java application on intermediate server where we write process to get the connection of this two database servers.
    From java application we call the procedure for selecting data from Oracle 10g and insert into oracle 9i database.
    What is the best way to achieve?
    Or You also suggest any other way to achieve
    ( As per this scenario materialized view is working ? )

    Thanks freiser,
    But it create another problem as per my business logic, There will be two database server , one is online server where online user fill the form which is generated by java, spring , hibernate and using database 10 g.
    at day end i need to execute a process that transferring data from online server to offline server that is in oracle database 9i. This process is scheduled. Some security reason client do not kept this two database on same network.
    My challenge is that transfer data from online server to offline server with applying client security norms.
    I have option like
    1) Using Oracle replication method, creating materialized view on remote server , refreshing it at regular interval. but database connectivity is not contineous, should i go for that ?
    2) Write java application on intermediate server where we write process to get the connection of this two database servers. From java application we call the procedure for selecting data from Oracle 10g and insert into oracle 9i database and using flag on both data to identified how many rows are transfered and how many remaining for trasfer.
    Please tell me what is best way to acheive this ?

  • Getting no data when it got changed from Oracle Database 10g to 11G

    Hi All,
    Below decode column is not working in Oracle database 11G but it is working in 10g. Please advise.
    {DECODE('Y',DECODE(cr.segment4,DECODE(cr.segment5,'007','32020','N'),'Y','N')
    ,DECODE(SIGN(DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost ))),-1,DECODE(INSTR(pae.expenditure_type,'Accrual'),0
    ,pae.project_exchange_rate*DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost )),pae.project_exchange_rate*DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost ))*-1),( -1*pae.project_exchange_rate*DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost )) ))
    ,DECODE(dr.segment4,DECODE(dr.segment5,'007','32020','N'),'Y','N'),DECODE(SIGN(DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost ))),1
    ,pae.project_exchange_rate*DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost )),( pae.project_exchange_rate*DECODE(pacd.line_num_reversed,NULL,pae.raw_cost,( -1*pae.raw_cost)) ))) "Amount"
    Regards,

    WRONG FORUM!
    This forum is for sql developer questions only.
    Since this is not a SQL Developer question it should be posted in the SQL and PL/SQL forum
    PL/SQL
    Please mark this question ANSWERED and repost it in the other forum.

Maybe you are looking for

  • How to use many conditions in query

    Hi all, i have a situation,must prepare a report to find availability of it devices.they are given the specific ip of devices. my query SELECT   Resultdate, [SERVICE]  ,[SERVICE TYPE] ,[IP] , DailyAvailability   FROM [Orion].[dbo].[DepartmentNodesNew

  • How do I update itunes on MAC OS X 10.5.8?

    how do I update itunes on a Power Mac G5, MAC OS X 10.5.8? thanks

  • I cannot seem to get the speed of my Ipone 4S to improve

    The Iphone 4S is connected to my Airport Extreme which is in a network with an Express. The speed i get on my phone or ipad (second generation) seems to be maximized at 65 Mb/s, is that normal?

  • Adobe Form: Could not start Layout Designer (see long text) - FPUIFB 086

    Hello Gurus, I have an issue when I working in SFP transaction, after create interface and form, When I switch to Layout Tab, I get and issue, please check my image blow: Could anyone help me? Thanks!

  • Content Disappearing off ipod

    Like every night before work i delete some episodes of my iPod and put different ones on it, along with podcast and audio books. I'v done this for as long as i can remember. But Tonight after ejecting my iPod, my iPod is empty. only my photos and app