1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

utl_mail help needed

Discussion in 'SQL PL/SQL' started by MAABDOLAT, Oct 30, 2009.

  1. MAABDOLAT

    MAABDOLAT Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    HI...

    I am using oracle 10g and want to send email at my yahoo address using UTL_MAIL......
    please tell me how i can configue UTL_MAIL ( how to give host address, user , password)....
    I m doing all that using UTL_SMTP but i want to use UTL_MAIL,

    Code (SQL):

    -------------------ULT_SMTP CODE------------------

    CREATE OR REPLACE PROCEDURE send_mail (pSender       VARCHAR2,
                                           pRecipient    VARCHAR2,
                                           pSubject      VARCHAR2,
                                           pMessage      VARCHAR2)
    IS
       mailhost    CONSTANT VARCHAR2 (30) := 'smtp.mail.yahoo.com';
       crlf        CONSTANT VARCHAR2 (2) := CHR (13) || CHR (10);
       mesg        VARCHAR2 (1000);
       mail_conn   UTL_SMTP.connection;
    BEGIN
       mail_conn := UTL_SMTP.open_connection (mailhost, 25);
       mesg :=
             'Date: '
          || TO_CHAR (SYSDATE, 'dd Mon yy hh24:mi:ss')
          || crlf
          || 'From: <>'
          || crlf
          || 'Subject: '
          || pSubject
          || crlf
          || 'To: '
          || pRecipient
          || crlf
          || ''
          || crlf
          || pMessage;
       UTL_SMTP.command (mail_conn, 'AUTH LOGIN');
       UTL_SMTP.command (
          mail_conn,
          UTL_RAW.cast_to_varchar2 (
             UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw ('USER'))
          )
       );
       UTL_SMTP.command (
          mail_conn,
          UTL_RAW.cast_to_varchar2 (
             UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw ('PASSWORD'))
          )
       );
       UTL_SMTP.helo (mail_conn, mailhost);
       UTL_SMTP.mail (mail_conn, pSender);
       UTL_SMTP.rcpt (mail_conn, pRecipient);
       UTL_SMTP.DATA (mail_conn, mesg);
       UTL_SMTP.quit (mail_conn);
    END send_mail;

    u may also help me through MAABDOLAT@YAHOO.COM, Waiting for ur advice, please
     
  2. debasisdas

    debasisdas Active Member

    Messages:
    46
    Likes Received:
    3
    Trophy Points:
    90
    Location:
    Bangalore, India
    This link might be helpful for you.