UTL_SMTP:OPEN_CONNECTION

I'm trying to use the UTL_SMTP:OPEN_CONNECTION statment within PL/SQL to send email. I don't get any errors back on the statement but it's not executing the open statement. I'm sure the server and port number are correct. I can use telnet and execute the helo, sender, etc commands with no problem. I'm running on a Windows 2000 server and the code looks identical to the examples provided. I've verified JAVA is loaded but I'm at a complete loss at this point. Any thoughts or suggestions would be greatly welcome.

For Oracle 8i, it seems like the Java classes required for the PL/SQL packages are not loaded in some situations during the creation of Oracle database instance. Note that JServer option is required in order for the package to work. If the user has chosen JServer option during the creation of the database instance, he can do the following to load the class to SYS schema:
cd $ORACLE_HOME/plsql/jlib
loadjava -user sys/<sys's password> plsql.jarSYS's original password is "change_on_install" if the user hasn't changed the password yet.

Similar Messages

  • Sending email to multiple address using Utl_Smtp

    Hi,
    I want to send email to multiple address using the Utl_Smtp feature.
    When I am sending email to one email address in the To:Field it works fine.However, when I send
    to multiple address I am getting the below error.I am using a table(Email_test) to store all email id.
    Error report:
    ORA-29279: SMTP permanent error: 501 5.1.3 Invalid address
    ORA-06512: at "SYS.UTL_SMTP", line 20
    ORA-06512: at "SYS.UTL_SMTP", line 98
    ORA-06512: at "SYS.UTL_SMTP", line 240
    ORA-06512: at line 48
    29279. 00000 - "SMTP permanent error: %s"
    *Cause:    A SMTP permanent error occurred.
    *Action:   Correct the error and retry the SMTP operation.
    I am trying two options both ways I am getting error
    Option 1:
    Selecting two email id indivually in the select query as below
    select email into v_Recipient1 from Email_test where Key_name='U1';
    select email into v_Recipient2 from Email_test where Key_name='U2';
    v_Recipient := v_Recipient1||';'||v_Recipient2;
    Option 2:
    Is there a way to use option
    select email into v_Recipient1 from Email_test where Key_name='U4';
    ===========================================================
    Create table Script
    ===========================================================
    create table Email_test (Email varchar2(100),Key_name varchar2(10));
    insert into Email_test values ('[email protected]','U1');
    insert into Email_test values ('[email protected]','U2');
    insert into Email_test values ('[email protected]','U3')
    insert into Email_test values ('[email protected];[email protected];[email protected]','U4');
    select * from Email_test
    [email protected]                         U1
    [email protected]                         U2
    [email protected]                         U3
    [email protected];[email protected];[email protected]     U4
    select * from Email_test where Key_name in ('U1','U2','U3')
    [email protected]     U1
    [email protected]     U2
    [email protected]     U3
    select * from Email_test where Key_name='U4'
    [email protected];[email protected];[email protected]
    =======================================================
    PL/SQL Block
    ===========================================================
    declare
    v_From VARCHAR2(80) := '[email protected]';
    v_cc VARCHAR2(80);
    v_Recipient VARCHAR2(80) ;
    v_Recipient1 VARCHAR2(80) ;
    v_Recipient2 VARCHAR2(80) ;
    v_Subject VARCHAR2(80);
    v_Mail_Host VARCHAR2(50);
    v_Mail_Conn utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    begin
    --Mail Host name
    select VALUE into v_Mail_Host from Server_info where server_name = 'SMTPServer';
    select email into v_Recipient1 from Email_test where Key_name='U1';
    select email into v_Recipient2 from Email_test where Key_name='U2';
    v_Recipient := v_Recipient1||';'||v_Recipient2;
    --for CC
    select email into v_cc from Email_test where Key_name='U3';
    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.Rcpt(v_Mail_Conn, v_cc); -- To CC recepient
    utl_smtp.Rcpt(v_Mail_Conn, v_BCC); To BCC recepient
    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 ||
    'Cc: ' || v_cc || crlf ||
    'Content-Type: text/html;' ||crlf ||
    --'Hello this is a test email');
    crlf || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf );
    utl_smtp.Quit(v_mail_conn);
    end;
    Any suggestion how to approach this issue.
    Thank you

    Simple Mail Transfer Protocol RFC 5321 specifications.
          RCPT TO:<forward-path> [ SP <rcpt-parameters> ] <CRLF>
       The first or only argument to this command includes a forward-path
       (normally a mailbox and domain, always surrounded by "&gt;" and "&lt;"
       brackets) identifying one recipient.In other words, you can only define a SINGLE mailbox address at a time. Multiple addresses requires multiple repeats of this command verb, once per maibox.
    Do not confuse this and the To: tag line in the Mime header that contains a comma delimited list of recipients. That tag line can contain anything - it is not parsed, not checked, and not verified as matching the actual recipient mailboxes as specified via the RCPT TO verb.

  • How to send email attachments in any format by utl_smtp?

    Hi,
    I am Using this Script for Sending Mail With an Attachment,i run this Script(Oracle 11g Database R1) and i got this Message "PL/SQL procedure successfully completed." but still i have not received the mail.
    Please advice me....
    set serveroutput on
    /* Formatted on 2010/06/03 21:26 (Formatter Plus v4.8.8) */
    DECLARE
    v_file_handle UTL_FILE.file_type;
    v_email_server VARCHAR2 (100) := 'Email_Server;
    v_conn UTL_SMTP.connection;
    v_port NUMBER := 25;
    v_reply UTL_SMTP.reply;
    v_msg VARCHAR2 (32767);
    v_line VARCHAR2 (1000);
    v_message VARCHAR2 (1000);
    b_connected BOOLEAN := FALSE;
    v_sender VARCHAR2 (50) := '************';
    v_strt_day varchar2(100);
    v_end_day varchar2(100);
    crlf VARCHAR2 (2) := CHR (13) || CHR (10);
    recpt VARCHAR2 (255) := '*********';
    slp PLS_INTEGER := 300;
    pdirpath VARCHAR2 (50) := 'D:\Mail_Process';
    pfilename VARCHAR2 (50) := 'Multifile.html';
    p_stat number     := 0;
    BEGIN
    /***** Check if the file exists ****/
    BEGIN
    v_file_handle := UTL_FILE.fopen (pdirpath, pfilename, 'R');
    EXCEPTION
    WHEN UTL_FILE.invalid_path
    THEN
    p_stat := 99;
    RETURN;
    WHEN OTHERS
    THEN
    p_stat := 99;
    RETURN;
    END;
    /***** Try to connect for three times, do sleep in between for 5minutes *****/
    FOR i IN 1 .. 3
    LOOP
    BEGIN
    --open the connection with the smtp server and do the handshake
    v_conn := UTL_SMTP.open_connection (v_email_server, v_port);
    v_reply := UTL_SMTP.helo (v_conn, v_email_server);
    IF 250 = v_reply.code
    THEN
    b_connected := TRUE;
    EXIT;
    END IF;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_LOCK.sleep (slp);
    END;
    END LOOP;
    IF b_connected = FALSE
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    v_reply := UTL_SMTP.mail (v_conn, v_sender);
    IF 250 != v_reply.code
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    v_reply := UTL_SMTP.rcpt (v_conn, recpt);
    IF 250 != v_reply.code
    THEN
    p_stat := 99;
    RETURN;
    END IF;
    UTL_SMTP.open_data (v_conn);
    v_message :=
    'Sample Email This is an auto generated mail.
    Please do not reply to this mail.'
    || CHR (10);
    v_msg :=
    'Date: '
    || TO_CHAR (SYSDATE, 'Mon DD yy hh24:mi:ss')
    || crlf
    || 'From: '
    || v_sender
    || crlf
    || 'Subject: '
    || 'Sample file'
    || crlf
    || 'To: '
    || recpt
    || crlf
    || 'Mime-Version: 1.0'
    || crlf
    || 'Content-Type: multipart/mixed;
    boundary="DMW.Boundary.605592468"'
    || crlf
    || ''
    || crlf
    || v_message
    || crlf
    || ''
    || crlf
    || '--DMW.Boundary.605592468'
    || crlf
    || 'Content-Type: text/plain;
    name="v_message.txt"; charset=US-ASCII'
    || crlf
    || 'Content-Disposition: inline; filename="v_message.txt"'
    || crlf
    || 'Content-Transfer-Encoding: 7bit'
    || crlf
    || ''
    || crlf
    || v_message
    || crlf
    || crlf
    || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    /***** Prepare the attachment to be sent *****/
    v_msg :=
    crlf
    || '--DMW.Boundary.605592468'
    || crlf
    || 'Content-Type:
    application/octet-stream; name="'
    || pfilename
    || '"'
    || crlf
    || 'Content-Disposition: attachment; filename="'
    || pfilename
    || '"'
    || crlf
    || 'Content-Transfer-Encoding: 7bit'
    || crlf
    || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    LOOP
    BEGIN
    UTL_FILE.get_line (v_file_handle, v_line);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    EXIT;
    END;
    v_msg := '*** truncated ***' || crlf;
    v_msg := v_line || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    END LOOP;
    UTL_FILE.fclose (v_file_handle);
    v_msg := crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    v_msg := crlf || '--DMW.Boundary.605592468--' || crlf;
    UTL_SMTP.write_data (v_conn, v_msg);
    UTL_SMTP.close_data (v_conn);
    UTL_SMTP.quit (v_conn);
    EXCEPTION
    WHEN OTHERS
    THEN
    p_stat := 99;
    END;
    Thank You
    Shan

    I would recommend not to use home grown email solutions and use what we all use
    1. UTL_MAIL oracle package http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10802/u_mail.htm
    or
    2. SMTP rock solid solution http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt

  • Problem with utl_smtp.write_data - immediate help needed

    Hi,
    I have a sql code that generates a .csv file and sends it as an attachment through utl_smtp.
    Everything works fine but the .csv file's header gets broken after certain characters..wondering why this is happening..pls help.
    Please find my code below:
    SET define off;
    DECLARE
    --CURSOR VARIABLES
    v_meter_count NUMBER := 0;
    v_meter_max_count NUMBER := 0;
    v_sysdate DATE := TRUNC (SYSDATE);
    --MAIL VARIABLES
    v_run_date DATE := TRUNC (SYSDATE);
    crlf CONSTANT VARCHAR2 (10) := UTL_TCP.crlf;
    boundary CONSTANT VARCHAR2 (256)
    := '-----7D81B75CCC90D2974F7A1CBD';
    first_boundary CONSTANT VARCHAR2 (256) := '--' || boundary || crlf;
    last_boundary CONSTANT VARCHAR2 (256)
    := '--' || boundary || '--' || crlf;
    multipart_mime_type CONSTANT VARCHAR2 (256)
    := 'multipart/mixed; boundary="' || boundary || '"';
    conn UTL_SMTP.connection;
    from_name VARCHAR2 (255) := 'Nielsen Online';
    from_address VARCHAR2 (255)
    := '[email protected]';
    to_address VARCHAR2 (255)
    := '[email protected]';
    subject VARCHAR2 (255) := '';
    mime_type VARCHAR2 (255) := 'text/plain';
    attachment_file_name VARCHAR2 (255) := NULL;
    mailhost VARCHAR2 (255) := '127.0.0.1';
    --PANELISTS' DETAILS CURSOR
    CURSOR tam_panelists
    IS
    SELECT a.panel_sys_id, a.panel_site_id, a.login_id,
    b.recruit_start_date, c.meter_id, d.affiliate_id,
    d.afflt_member_id,
    (CASE
    WHEN b.last_active_date >= TRUNC (SYSDATE) - 30
    THEN 'Active'
    ELSE 'Inactive'
    END
    ) hh_status,
    (SELECT e.affiliate_description
    FROM pfshared3.lkp_affiliates e
    WHERE e.partner_id =
    NVL (d.affiliate_id, 0)
    AND e.pnl_sys_id = a.panel_sys_id) affiliate_description
    FROM mgtw.dat_ps_login_info a,
    mgtw.dat_ps_install_info b,
    mgtw.dat_ps_info c,
    mgtw.dat_ps_recruit_info d
    WHERE a.login_id LIKE 'tam%@tam%.com'
    AND a.panel_site_id = b.panel_site_id
    AND a.panel_sys_id = b.panel_sys_id
    AND a.panel_site_id = c.panel_site_id
    AND a.panel_sys_id = c.panel_sys_id
    AND a.panel_site_id = d.panel_site_id
    AND a.panel_sys_id = d.panel_sys_id
    AND a.active_flag = 1
    AND b.first_mtr_install_date IS NOT NULL
    AND b.last_active_date IS NOT NULL;
    --PANELISTS' PC DETAILS CURSOR
    CURSOR pc_activity (p_meter_id IN VARCHAR2)
    IS
    SELECT cpt_guid, first_active_date, last_active_date,
    TO_CHAR(first_install_date,'MM/DD/YYYY HH:MI') first_install_dt,
    (TRUNC (SYSDATE) - last_active_date) inactive_days,
    (CASE
    WHEN last_active_date >= TRUNC (SYSDATE) - 30
    THEN 'Active'
    ELSE 'Inactive'
    END
    ) status
    FROM pfshared3.dat_pnl_computers
    WHERE meter_id = p_meter_id
    ORDER BY last_active_date DESC;
    --RECORD TYPE FOR PANELISTS' DETAILS
    TYPE t_panelist_set IS TABLE OF tam_panelists%ROWTYPE;
    v_panelist_data t_panelist_set;
    --RECORD TYPE FOR PANELISTS' PC DETAILS
    TYPE t_pc_set IS TABLE OF pc_activity%ROWTYPE;
    v_pc_data t_pc_set;
    PROCEDURE send_header (NAME IN VARCHAR2, header IN VARCHAR2)
    IS
    BEGIN
    UTL_SMTP.write_data (conn, NAME || ': ' || header || crlf);
    END;
    BEGIN
    --MAX METER COUNT
    BEGIN
    SELECT MAX(COUNT (meter_id))
    INTO v_meter_max_count
    FROM pfshared3.dat_pnl_computers
    WHERE last_active_date IS NOT NULL
    GROUP BY meter_id;
    EXCEPTION
    WHEN OTHERS
    THEN
    v_meter_max_count := 0;
    END;
    DBMS_OUTPUT.put_line ( 'STARTED - '
    || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH:MI:SS')
    conn := UTL_SMTP.open_connection (mailhost);
    UTL_SMTP.helo (conn, mailhost);
    UTL_SMTP.mail (conn, '< ' || from_address || ' >');
    UTL_SMTP.rcpt (conn, '< ' || to_address || ' >');
    UTL_SMTP.open_data (conn);
    send_header ('From', '"' || from_name || '" <' || from_address || '>');
    send_header ('To', '' || to_address || '');
    send_header ('Date', TO_CHAR (SYSDATE, 'dd Mon yy hh24:mi:ss'));
    subject := 'TW Daily Activity Report' || ' - ' || v_run_date;
    send_header ('Subject', subject);
    send_header ('Content-Type', multipart_mime_type);
    -- Close header section by a crlf on its own
    UTL_SMTP.write_data (conn, crlf);
    -- mime header
    UTL_SMTP.write_data (conn, first_boundary);
    send_header ('Content-Type', mime_type);
    UTL_SMTP.write_data (conn, crlf);
    UTL_SMTP.write_data (conn, crlf);
    -- add the attachment
    attachment_file_name := 'TW_Daily_Activity_Report_' || v_run_date || '.txt';
    UTL_SMTP.write_data (conn, first_boundary);
    send_header ('Content-Type', mime_type);
    send_header ('Content-Disposition',
    'attachment; filename= ' || attachment_file_name
    UTL_SMTP.write_data (conn, crlf);
    --CREATING HEADERS
    UTL_SMTP.write_data (conn,
    'Date of Reporting'
    || ','
    || 'Panelist ID'
    || ','
    || 'Meter ID'
    || ','
    || 'Panelist Email(Username)'
    || ','
    || 'Vendor'
    || ','
    || 'Affiliate ID'
    || ','
    || 'UID'
    || ','
    || 'Enrollment Date'
    || ','
    || 'HH Status'
    || ','
    || 'Registered PC in the HH'
    || ','
    FOR k IN 1 .. v_meter_max_count
    LOOP
    UTL_SMTP.write_data (conn,
    'Installation Date/Time MM/DD/YYYY HH:MI PC' || k || ',' || 'PC '|| k ||': Status' || ',' || 'PC '|| k ||': Date of First log' || ',' || 'PC '|| k ||': Date of Last log' || ',' || 'PC '|| k ||': Days since Last Activity' || ',' || 'PC '|| k ||': Computer ID' || ','
    END LOOP;
    UTL_SMTP.write_data (conn, crlf);
    --OPENING PANELISTS' DETAILS CURSOR
    OPEN tam_panelists;
    --FETCHING PANELISTS' DETAILS CURSOR
    FETCH tam_panelists
    BULK COLLECT INTO v_panelist_data;
    FOR i IN v_panelist_data.FIRST .. v_panelist_data.LAST
    LOOP
    --METER COUNT
    BEGIN
    SELECT COUNT (meter_id)
    INTO v_meter_count
    FROM pfshared3.dat_pnl_computers
    WHERE meter_id = v_panelist_data (i).meter_id
    GROUP BY meter_id;
    EXCEPTION
    WHEN OTHERS THEN
    v_meter_count := 0;
    END;
    --OPENING PANELISTS' PC DETAILS CURSOR
    OPEN pc_activity (v_panelist_data (i).meter_id);
    --FETCHING PANELISTS' PC DETAILS CURSOR
    FETCH pc_activity
    BULK COLLECT INTO v_pc_data;
    UTL_SMTP.write_data (conn,
    v_sysdate
    || ','
    || v_panelist_data (i).panel_site_id
    || ','
    || v_panelist_data (i).meter_id
    || ','
    || v_panelist_data (i).login_id
    || ','
    || v_panelist_data (i).affiliate_description
    || ','
    || v_panelist_data (i).affiliate_id
    || ','
    || v_panelist_data (i).afflt_member_id
    || ','
    || v_panelist_data (i).recruit_start_date
    || ','
    || v_panelist_data (i).hh_status
    || ','
    || v_meter_count
    || ','
    FOR j IN v_pc_data.FIRST .. v_pc_data.LAST
    LOOP
    UTL_SMTP.write_data (conn,
    v_pc_data (j).first_install_dt
    || ','
    || v_pc_data (j).status
    || ','
    || v_pc_data (j).first_active_date
    || ','
    || v_pc_data (j).last_active_date
    || ','
    || v_pc_data (j).inactive_days
    || ','
    || v_pc_data (j).cpt_guid
    || ','
    END LOOP;
    UTL_SMTP.write_data (conn, crlf);
    CLOSE pc_activity;
    END LOOP;
    CLOSE tam_panelists;
    -- CLOSE THE MESSAGE
    UTL_SMTP.write_data (conn, last_boundary);
    -- CLOSE CONNECTION
    UTL_SMTP.close_data (conn);
    UTL_SMTP.quit (conn);
    DBMS_OUTPUT.put_line ( 'ENDED - '
    || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH:MI:SS')
    RETURN;
    EXCEPTION
    WHEN UTL_SMTP.transient_error OR UTL_SMTP.permanent_error
    THEN
    UTL_SMTP.quit (conn);
    raise_application_error
    (-20000,
    'Failed to send mail due to the following error: '
    || SQLERRM
    WHEN OTHERS
    THEN
    raise_application_error
    (-20000,
    'Script failed due to the following error: '
    || SQLERRM
    RETURN;
    END;
    Please find below the header of the .csv file generated:
    Date of Reporting     Panelist ID     Meter ID     Panelist Email(Username)     Vendor     Affiliate ID     UID     Enrollment Date     HH Status     Registered PC in the HH     Installation Date/Time MM/DD/YYYY HH:MI PC1     PC 1: Status     PC 1: Date of First log     PC 1: Date of Last log     PC 1: Days since Last Activity     PC 1: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC2     PC 2: Status     PC 2: Date of First log     PC 2: Date of Last log     PC 2: Days since Last Activity     PC 2: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC3     PC 3: Status     PC 3: Date of First log     PC 3: Date of Last log     PC 3: Days since Last Activity     PC 3: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC4     PC 4: Status     PC 4: Date of First log     PC 4: Date of Last log     PC 4: Days since Last Activity     PC 4: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC5     PC 5: Status     PC 5: Date of First log     PC 5: Date of Last log     PC 5: Days since Last Activity     PC 5: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC6     PC 6: Status     PC 6: Date of First log     PC 6: Date of Last log     PC 6: Days since Last Activity     PC 6: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC7     PC 7: Status     PC 7: Date of First log     PC 7: Date of Last log     PC 7: Days since Last Activity     PC 7: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC8     PC 8: Status     PC 8: Date of First log     PC 8: Date of Last log     PC 8: Days since Last Activity     PC 8: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC9     PC 9: Status     PC 9: Date of First log     PC 9: Date of Last log     PC 9: Days since Last Activity     PC 9: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC10     PC 10: Status     PC 10: Date of First log     PC 10: Date of Last log     PC 10: Days since Last Activity     PC 10: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC11     PC 11: Status     PC 11: Date of First log     PC 11: Date of Last log     PC 11: Days since Last Activity     PC 11: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC12     PC 12: Status     PC 12: Date of First log     PC 12: Date of Last log     PC 12: Days since Last Activity     PC 12: Computer ID     Installation Date/Time MM/DD/YYYY HH:MI PC13     PC!
    *13: Sta                                                                                                                                                                                                                                                                                                                                                                                                                               *
    tus     PC 13: Date of First log     PC 13: Date of Last log     PC 13: Days since Last Activity     PC 13: Computer ID                                                                                                                                                                     
    The one highlighted in bold is the broken header.
    Please provide a solution to this.
    Thanks
    Monika
    Edited by: 953348 on Aug 18, 2012 8:00 AM

    I can't provide a solution but maybe a little help. With the header line you posted here it seems to me that a new line starts after 2048 = 2^11 characters. This might be a limitation or a length of any variable in the package.
    Maybe you can change this value or shorten the texts in the header to stay below this limit.
    A few more things:
    - the code, that you posted here became destroyed in lines like UTL_SMTP.mail (conn, '< ' .... because the forum software tried to find html-code between the "<" and ">" signs.
    - you can mark code in your postings with (see FAQ). It makes code better readable but it does not help with the "<" and ">" signs.
    - you left your e-mail-address in the header of the code. I guess this was not your intention. You can edit it and remove the address even after posting a message.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to use UTL_SMTP to send email with existing file attachment

    Hello! I am trying to create a pl/sql procedure that lets me send an email and include an existing file to a email address. So far, I found information on how to send a file and create an attachment with information I put in the procedure. This is NOT what I'm trying to do. I'm trying to send an email and include an attachment for a file that already exists. I need the pre-existing file to be sent to the email recipient.
    This is how far I've gotten, but this only allows me to CREATE an attachment with the information I put in it from the procedure. I got it from the following site:
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'Weekly Invoice Report';
       v_Mail_Host  VARCHAR2(30) := 'mail.mycompany.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 ||
        'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
        'Content-Type: multipart/mixed;'|| crlf ||
        ' boundary="-----SECBOUND"'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'This is a test'|| crlf ||     -- Message body
        'of the email attachment'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        ' name="ap_inv_supplier_cc10.txt"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="ap_inv_supplier_cc10.txt"'|| crlf ||
        crlf ||
        'TXT,file,attachment'|| crlf ||     -- Content of attachment  (THIS IS MY PROBLEM!  I NEED TO BE ABLE TO ATTACH AN EXISTING FILE, NOT CREATE A NEW ONE)
        crlf ||
        '-------SECBOUND--'               -- End MIME mail
      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;
    /

    First, you must create a directory object
    create directory ORALOAD as '/home/ldcgroup/ldccbc/'
    /Study the Prerequisites in the link I posted above, or else you will not be able to read/write files from the above directory object
    "fname" relates to the file name that you read from.
    In the code below, it is also the name of the file that you are attaching.
    Although they can be different!
    l_Output is the contents of the file.
    declare
    vInHandle  utl_file.file_type;
    flen       number;
    bsize      number;
    ex         boolean;
    l_Output   raw(32767);
    fname      varchar2(30) := 'ap_inv_supplier_cc10.txt';
    vSender    varchar2(30) := '[email protected]';
    vRecip     varchar2(30) := '[email protected]';
    vSubj      varchar2(50) := 'Weekly Invoice Report';
    vAttach    varchar2(50) := 'ap_inv_supplier_cc10.txt';
    vMType     varchar2(30) := 'text/plain; charset=us-ascii';
    begin
      utl_file.fgetattr('ORALOAD', fname, ex, flen, bsize);
      vInHandle := utl_file.fopen('ORALOAD', fname, 'R');
      utl_file.get_raw (vInHandle, l_Output);
      utl_file.fclose(vInHandle);
      utl_mail.send_attach_raw(sender       => vSender
                              ,recipients   => vRecip
                              ,subject      => vsubj
                              ,attachment   => l_Output
                              ,att_inline   => false
                              ,att_filename => fname);
    end;
    /

  • How can I email using UTL_SMTP with a csv file as an attachment?

    Dear All,
    It would be great if someone could help me. I am trying to use UTL_SMTP to email with a csv file as attachment. I do get an email with a message but no attachment arrives with it.
    In fact the code used for attaching the csv file gets appended in the message body in the email.
    CREATE OR REPLACE PROCEDURE test_mail
    AS
    SENDER constant VARCHAR2(80) := '[email protected]';
    MAILHOST constant VARCHAR2(80) := 'mailhost.xxxx.ac.uk';
    mail_conn utl_smtp.connection;
    lv_rcpt VARCHAR2(80);
    lv_mesg VARCHAR2(9900);
    lv_subject VARCHAR2(80) := 'First Test Mail';
    lv_brk VARCHAR2(2) := CHR(13)||CHR(10);
    BEGIN
    mail_conn := utl_smtp.open_connection(mailhost, 25) ;
    utl_smtp.helo(mail_conn, MAILHOST) ;
    dbms_output.put_line('Sending Email to : ' ||lv_brk||'Suhas Mitra' ) ;
    lv_mesg := 'Date: '||TO_CHAR(sysdate,'dd Mon yy hh24:mi:ss')||lv_brk||
    'From: <'||SENDER||'>'||lv_brk||
    'Subject: '||lv_subject||lv_brk||
    'To: '||'[email protected]'||lv_brk||
    'MIME-Version: 1.0'||lv_brk||
    'Content-type:text/html;charset=iso-8859-1'||lv_brk||
    ' boundary="-----SECBOUND"'||
    ''||lv_brk||
    '-------SECBOUND'||
    'Some Message'
              || lv_brk ||
    '-------SECBOUND'||
              'Content-Type: text/plain;'|| lv_brk ||
              ' name="xxxx.csv"'|| lv_brk ||
              'Content-Transfer_Encoding: 8bit'|| lv_brk ||
              'Content-Disposition: attachment;'|| lv_brk ||
              ' filename="xxxx.csv"'|| lv_brk ||
              lv_brk ||
    'CSV,file,attachement'|| lv_brk ||     -- Content of attachment
    lv_brk||
    '-------SECBOUND' ;
    dbms_output.put_line('lv_mesg : ' || lv_mesg) ;
    utl_smtp.mail(mail_conn, SENDER) ;
    lv_rcpt := '[email protected]';
    utl_smtp.rcpt(mail_conn, lv_rcpt) ;
    utl_smtp.data(mail_conn, lv_mesg) ;
    utl_smtp.quit(mail_conn);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    NULL ;
    WHEN OTHERS THEN
    dbms_output.put_line('Error Code : ' || SQLCODE) ;
    dbms_output.put_line('Error Message : ' || SQLERRM) ;
    utl_smtp.quit(mail_conn) ;
    END;

    LKBrwn_DBA wrote:
    Use UTL_MAIL instead.That package is an utter disappointment - and an excellent example IMO of how not to design an application programming interface. Even the source code is shoddy.. I mean, having to resort to a GOTO statement....!!?? The person(s) who wrote that package are sorely lacking in even the most basic of programming skills if structured programming is ignored and a spaghetti command used instead.
    No wonder the public interface of that code is equally shabby and thoughtless... The mail demo code posted by Oracle was better written than this "+package+" they now have bundled as the official Mail API.
    I dunno.. if I was in product management there would have been hell to pay over pushing cr@p like that to customers.

  • Sending Mails to Multiple Recipients using UTL_SMTP

    create or replace procedure send_mail(msg_text varchar2) is
    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('outlook.abc.com');
    utl_smtp.helo(c, 'abc.com');
    utl_smtp.mail(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.open_data(c);
    send_header('From', '"root" <[email protected]>');
    send_header('To', '"abc" <[email protected]>');
    send_header('Subject', 'WARNING: Salary has been changed');
    utl_smtp.write_data(c, utl_tcp.CRLF || msg_text);
    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;
    ==============
    when I execute the above using
    sql> exec send_mail('hihihih');
    I am getting the mails..no problems...
    So..I created the following trigger and used the above procedure to send the mail...
    CREATE OR REPLACE TRIGGER test_emp_table_trg
    AFTER UPDATE
    ON test_emp_table
    FOR EACH ROW
    WHEN (NEW.sal <> OLD.sal)
    DECLARE
    l_employee_name VARCHAR2 (240);
    l_old_sal VARCHAR2 (240);
    l_new_sal VARCHAR2 (240);
    l_message VARCHAR2 (240);
    BEGIN
    /* Gets the employee full name */
    BEGIN
    SELECT ename
    INTO l_employee_name
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_employee_name := NULL;
    END;
    /* Gets the old Salary */
    BEGIN
    SELECT sal
    INTO l_old_sal
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_old_sal := 0;
    END;
    /* Gets the new salary */
    BEGIN
    SELECT sal
    INTO l_new_sal
    FROM test_emp_table
    WHERE empno= :NEW.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_new_sal := 0;
    END;
    l_message:=
    'Employee Name= '
    || l_employee_name
    || 'Old Salary= '
    || l_old_sal
    || 'New Salary= '
    || l_new_sal;
    BEGIN
    send_mail (l_message);
    END;
    END;
    ===================
    I am not getting desired output..what might be problem friends...I am getting 0 values for old salary and new salary......
    One more thing..when i use 2 receipts in the send_mail procedure like this...I added the following lines in the procedure to send to multiple receipents..
    ======
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    =============
    Pleas have a look and correct me, where i went wrong....
    Edited by: oraDBA2 on Sep 22, 2008 3:12 PM

    Hi, You can use the following routine to send mail to multiple recipients through utl_smtp.
    create or replace package mail_pkg
    as
    type array is table of varchar2(255);
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    create or replace package body mail_pkg
    begin
    g_crlf char(2) default chr(13)||chr(10);
    g_mail_conn utl_smtp.connection;
    g_mailhost varchar2(255) := 'ur mail server';
    function address_email( p_string in varchar2,
    p_recipients in array ) return varchar2
    is
    l_recipients long;
    begin
    for i in 1 .. p_recipients.count
    loop
    utl_smtp.rcpt(g_mail_conn, p_recipients(i));
    if ( l_recipients is null )
    then
    l_recipients := p_string || p_recipients(i) ;
    else
    l_recipients := l_recipients || ', ' || p_recipients(i);
    end if;
    end loop;
    return l_recipients;
    end;
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    is
    l_to_list long;
    l_cc_list long;
    l_bcc_list long;
    l_date varchar2(255) default
    to_char( SYSDATE, 'dd Mon yy hh24:mi:ss' );
    procedure writeData( p_text in varchar2 )
    as
    begin
    if ( p_text is not null )
    then
    utl_smtp.write_data( g_mail_conn, p_text || g_crlf );
    end if;
    end;
    begin
    g_mail_conn := utl_smtp.open_connection(g_mailhost, 25);
    utl_smtp.helo(g_mail_conn, g_mailhost);
    utl_smtp.mail(g_mail_conn, p_sender_e_mail);
    l_to_list := address_email( 'To: ', p_to );
    l_cc_list := address_email( 'Cc: ', p_cc );
    l_bcc_list := address_email( 'Bcc: ', p_bcc );
    utl_smtp.open_data(g_mail_conn );
    writeData( 'Date: ' || l_date );
    writeData( 'From: ' || nvl( p_from, p_sender_e_mail ) );
    writeData( 'Subject: ' || nvl( p_subject, '(no subject)' ) );
    writeData( l_to_list );
    writeData( l_cc_list );
    utl_smtp.write_data( g_mail_conn, '' || g_crlf );
    utl_smtp.write_data(g_mail_conn, p_body );
    utl_smtp.close_data(g_mail_conn );
    utl_smtp.quit(g_mail_conn);
    end;
    end;
    begin
    mail_pkg.send
    (p_sender_e_mail => 'urmail',
    p_from => 'urmail',
    p_to => mail_pkg.array( 'urmail','othersmail' ),
    p_cc => mail_pkg.array( ' othermail ' ),
    p_bcc => mail_pkg.array( '' ),
    p_subject => 'This is a subject',
    p_body => 'Hello Buddy, this is the mail you need' );
    end;
    /

  • UTL_SMTP - Error while using Cc

    Hi All,
    I have got a issue regarding sending mails via pl/sql. Unable to add an mail id using Cc. The procedure looks something like this.
    CREATE OR REPLACE PROCEDURE test_mail is
    mailhost VARCHAR2(100) := 'GASVREXC01';
    conn UTL_SMTP.CONNECTION;
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    mesg VARCHAR2( 1000 );
    BEGIN
    conn:= utl_smtp.open_connection( mailhost, 25 );
    utl_smtp.helo( conn, mailhost );
    utl_smtp.mail( conn, '[email protected]' );
    utl_smtp.rcpt( conn, '<[email protected]>' );
    utl_smtp.rcpt( conn, 'Cc:[email protected]' );
    mesg:= 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
    'From: User1 <[email protected]>' || crlf ||
    'Subject: Just testing' || crlf ||
    'To: Biju Varghese <[email protected]>' || crlf ||
    'Cc: Biju <[email protected]>' || crlf ||
    '' || crlf ||
    ' This is just a test, please disregard. ' || crlf ||
    utl_smtp.data( conn, mesg );
    utl_smtp.quit( conn );
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    utl_smtp.quit(conn);
    raise_application_error(-20000,
    'Failed tosend mail due to the following error: ' || sqlerrm);
    WHEN OTHERS THEN
    raise_application_error(-20001,
    'The following error has occured: ' || sqlerrm);
    END;
    Procedure created.
    SQL> execute test_mail;
    BEGIN test_mail; END;
    ERROR at line 1:
    ORA-20000: Failed tosend mail due to the following error: ORA-29279: SMTP
    permanent error: 553 malformed address: bcc:[email protected]
    ORA-06512: at "SYS.TEST_MAIL", line 28
    ORA-06512: at line 1
    Can someone help me out, as how can i use a Cc feature. We are using Microsoft Outlook. If i comment the line for Cc it works fine. Any help would be gr8
    Thanks
    Biju

    Can you back that statement about an Oracle UTL_SMTP bug up with an actual bug number??
    From what you have posted, this is not a bug!! but expected and documented (RFC'ed) SMTP server behaviour.
    My proof:
    /home/billy> telnet mail 25
    Trying 165.143.128.26...
    Connected to mail
    Escape character is '^]'.
    220 CNTRRA20-GTW01 [CNTRRA20-GTW01] Thu, 06 Mar 2008 14:26:26 +0200
    HELO 10.251.93.58
    250 CNTRRA20-GTW01 Hello [10.251.93.58]
    MAIL FROM: naveen <[email protected]>
    501 naveen <[email protected]> : illegal character(s) in domain string
    MAIL FROM: NAVEEN
    501 NAVEEN : domain string is NULL.
    quit
    221 CNTRRA20-GTW01 closing connection. Goodbye!
    Connection closed by foreign host.
    /home/billy>
    As you can clearly see, the SMTP server expects a DOMAIN name as part of the MAIL FROM address. It also does not accept the alternative format suggested.
    Yes, not all SMTP servers are equal and some support additional formatting.
    But to imply that because the SMTP server does not accept your address formatted as string NAVEEN, it is a UTL_SMTP problem, sounds like a smelly one to me.

  • Sending html email using utl_smtp

    (Oracle 8.1.7)
    I'm using the following procedure to send an HTML formatted e-mail. It sends email but I'm seeing in Outlook html code instead of formatted mail. (It sends text like :
    a bit of text
    --a1b2c3d4e3f2g1
    content-type: text/html;
    <html><head></head><body><B>HELLO </B></body></html>
    a1b2c3d4e3f2g1
    What can I solve this problem?
    Thanks in advance...
    its usage :
    html_email('smo@....','smo2@...','This is a subject','a bit of text', '<html><head></head><body><B>HELLO </B></body></html>', 'some hostname',25);
    CREATE OR REPLACE procedure html_email(
    p_to in varchar2,
    p_from in varchar2,
    p_subject in varchar2,
    p_text in varchar2 default null,
    p_html in varchar2 default null,
    p_smtp_hostname in varchar2,
    p_smtp_portnum in varchar2)
    is
    l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';
    l_connection utl_smtp.connection;
    l_body_html clob := empty_clob; --This LOB will be the email message
    l_offset number;
    l_ammount number;
    l_temp varchar2(32767) default null;
    begin
    l_connection := utl_smtp.open_connection( p_smtp_hostname, p_smtp_portnum );
    utl_smtp.helo( l_connection, p_smtp_hostname );
    utl_smtp.mail( l_connection, p_from );
    utl_smtp.rcpt( l_connection, p_to );
    l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);
    l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
    l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
    l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
    l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);
    l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
    chr(34) || l_boundary || chr(34) || chr(13) ||
    chr(10);
    -- Write the headers
    dbms_lob.createtemporary( l_body_html, false, 10 );
    dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
    -- Write the text boundary
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    l_temp := '--' || l_boundary || chr(13)||chr(10);
    l_temp := l_temp || 'content-type: text/plain; charset=us-ascii' ||
    chr(13) || chr(10) || chr(13) || chr(10);
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Write the plain text portion of the email
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
    -- Write the HTML boundary
    l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
    chr(13) || chr(10);
    l_temp := l_temp || 'content-type: text/html;' ||
    chr(13) || chr(10) || chr(13) || chr(10);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Write the HTML portion of the message
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
    -- Write the final html boundary
    l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Send the email in 1900 byte chunks to UTL_SMTP
    l_offset := 1;
    l_ammount := 1900;
    utl_smtp.open_data(l_connection);
    while l_offset < dbms_lob.getlength(l_body_html) loop
    utl_smtp.write_data(l_connection,
    dbms_lob.substr(l_body_html,l_ammount,l_offset));
    l_offset := l_offset + l_ammount ;
    l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
    end loop;
    utl_smtp.close_data(l_connection);
    utl_smtp.quit( l_connection );
    dbms_lob.freetemporary(l_body_html);
    end;

    There have been many very good threads on sending email using the UTL_SMTP on the forum including threads that deal with HTML formated mail.
    The basic process is to the same as with sending regular (non HTML) mail, but you add some additional headers to the mail message as well as additional formatting to the message body (e.g. HTML tags as needed).
    Specifically you need to add the two following headers:
    MIME-Version: 1.0
    Content-type: text/html

  • Sending  mail using utl_smtp

    (Oracle 8.1.7)
    I'm using the following procedure to send an HTML formatted e-mail. It sends email but I'm seeing in Outlook html code instead of formatted mail. (It sends text like :
    a bit of text
    --a1b2c3d4e3f2g1
    content-type: text/html;
    <html><head></head><body><B>HELLO </B></body></html>
    a1b2c3d4e3f2g1
    What can I solve this problem?
    Thanks in advance...
    its usage :
    html_email('smo@....','smo2@...','This is a subject','a bit of text', '<html><head></head><body><B>HELLO </B></body></html>', 'some hostname',25);
    CREATE OR REPLACE procedure html_email(
    p_to in varchar2,
    p_from in varchar2,
    p_subject in varchar2,
    p_text in varchar2 default null,
    p_html in varchar2 default null,
    p_smtp_hostname in varchar2,
    p_smtp_portnum in varchar2)
    is
    l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';
    l_connection utl_smtp.connection;
    l_body_html clob := empty_clob; --This LOB will be the email message
    l_offset number;
    l_ammount number;
    l_temp varchar2(32767) default null;
    begin
    l_connection := utl_smtp.open_connection( p_smtp_hostname, p_smtp_portnum );
    utl_smtp.helo( l_connection, p_smtp_hostname );
    utl_smtp.mail( l_connection, p_from );
    utl_smtp.rcpt( l_connection, p_to );
    l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);
    l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
    l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
    l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
    l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);
    l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
    chr(34) || l_boundary || chr(34) || chr(13) ||
    chr(10);
    -- Write the headers
    dbms_lob.createtemporary( l_body_html, false, 10 );
    dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
    -- Write the text boundary
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    l_temp := '--' || l_boundary || chr(13)||chr(10);
    l_temp := l_temp || 'content-type: text/plain; charset=us-ascii' ||
    chr(13) || chr(10) || chr(13) || chr(10);
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Write the plain text portion of the email
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
    -- Write the HTML boundary
    l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
    chr(13) || chr(10);
    l_temp := l_temp || 'content-type: text/html;' ||
    chr(13) || chr(10) || chr(13) || chr(10);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Write the HTML portion of the message
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
    -- Write the final html boundary
    l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);
    l_offset := dbms_lob.getlength(l_body_html) + 1;
    dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
    -- Send the email in 1900 byte chunks to UTL_SMTP
    l_offset := 1;
    l_ammount := 1900;
    utl_smtp.open_data(l_connection);
    while l_offset < dbms_lob.getlength(l_body_html) loop
    utl_smtp.write_data(l_connection,
    dbms_lob.substr(l_body_html,l_ammount,l_offset));
    l_offset := l_offset + l_ammount ;
    l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
    end loop;
    utl_smtp.close_data(l_connection);
    utl_smtp.quit( l_connection );
    dbms_lob.freetemporary(l_body_html);
    end;

    This forum is for Forms questions. Try asking this on another forum, such as the database forum or the PL/SQL forum.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • What is utl_tcp and utl_smtp tx_timeout parameter do ?

    Hi All,
    I tried the following in DBServerA (10.10.10.10 - for example) :
    test_conn := utl_tcp.open_connection (remote_host => '10.2.90.100'
    ,remote_port => 25
    ,tx_timeout => 10 );
    l_mail_conn := UTL_SMTP.OPEN_CONNECTION(host => '10.2.90.100'
    ,port => 25
    ,tx_timeout => 10);
    now, in DBServerA, the smtp host 10.2.90.100 can be ping'd - however doing a telnet (e.g. telnet 10.2.90.100 25) will fail - because port 25 is blocked by the firewall for the smtp host.
    Using UTL_TCP I get the following error in around 3 to 4 minutes:
    "ORA-29260: network error: TNS:operation timed out"
    Using UTL_SMTP I get the following error in around 3 to 4 minutes:
    "ORA-29278: SMTP transient error: 421 Service not available"
    My question now is although I set the tx_timeout parameter for both procedures with a 10 seconds value - why is that I only get the error message at around 3 to 4 minutes?
    What I really want to achieve is - how can I get immediate feedback if my PL/SQL program can connect to 10.2.90.100 at port 25 ?
    Is there a way? - I would just like to control the connection timeout timing precisely - and not relay on external settings (e.g. O/S)
    The reason for the above requirement is to implement a "Primary SMTP Service" and a "Secondary SMTP Service" - essentially if the Primary SMTP Host IP Address fails to connect, then the PL/SQL code should try to connect to the "Secondary SMTP Host IP Address".
    One thing to note is that during this 3 to 4 minutes wait time - the Oracle Connection is held up - if this now happens to the many application calls to the PL/SQL procedure - then potentially there can be a problem in many Oracle Connections opening up. - so a PL/SQL solution that would provide an immediate feedback if the SMTP service is accessible or not is ideal.
    I'm using Oracle 10gR1 @ Solaris
    The following command below will give me 3 minutes (agreed upon to not change this setting as it will affect all other programs/services)
    "/usr/sbin/ndd -get /dev/tcp tcp_ip_abort_cinterval"
    The following command below will give me 1 minute (agreed upon to not change this setting as it will affect all other programs/services)
    "/usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval"
    Please help!
    Many Thanks,
    Henry

    Hi,
    Anyone? I saw many articles in Metalink regarding the tx_timeout parameter - also one which a customer is demanding an explanation and enhancement on the tx_timeout parameter. Come to think of it, when will it work? only for Exchange? (found some hints on this in metalink).
    But still, is there no other way to immediately know if the port has opened or not?
    I will try the following: http://www.oraclenerd.com/2008/11/javaplsql-port-scanner-ii.html , but still would prefer a PL/SQL solution though.
    Many Thanks,
    Henry Wu

  • Sending UTL_SMTP mail with Multiple attachment

    Hi,
    My Environment ----> Oracle Database 11g r1 on Windows 2003 Server (64Bit).
    The below script i used for sending mail with single attachment now i am trying to send mail with multiple attachment please tell me how to achieve this
    DECLARE
    /*LOB operation related varriables */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    RAISE;
    END;
    Thank you
    Shan

    Hi Saubhik
    Thanks for your reply, below script i used to send mail with multiple attachments, plsql code is executing without any error messages and i am also able to receive mail with the multiple attachment.
    i used your code which u posted in OTN then i changed little bit as per my need, output is ok.but the problem is if i want to add one more file then i have to add more varaiables in the code. i want to make the code which i can add more attachments without adding more varaiables i don't know the way to do this. can u please give me some hints.
    Thanks for your help
    Shan
    Script Used:
    DECLARE
    /*LOB operation related varriables01 */
    v_src_loc BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT.LOG');
    l_buffer RAW(54);
    l_amount BINARY_INTEGER := 54;
    l_pos INTEGER := 1;
    l_blob BLOB := EMPTY_BLOB;
    l_blob_len INTEGER;
    v_amount INTEGER;
    /*LOB operation related varriables02 */
    v_src_loc2 BFILE := BFILENAME('DATA_PUMP_DIR', 'EXPORT1.LOG');
    l_buffer2 RAW(54);
    l_amount2 BINARY_INTEGER := 54;
    l_pos2 INTEGER := 1;
    l_blob2 BLOB := EMPTY_BLOB;
    l_blob_len2 INTEGER;
    v_amount2 INTEGER;
    /*UTL_SMTP related varriavles. */
    v_connection_handle UTL_SMTP.CONNECTION;
    v_from_email_address VARCHAR2(30) := '[email protected]';
    v_to_email_address VARCHAR2(30) := '[email protected]';
    v_smtp_host VARCHAR2(30) := 'MAIL.EXPORT.COM'; --My mail server, replace it with yours.
    v_subject VARCHAR2(30) := 'MULTIPLE Attachment Test';
    l_message VARCHAR2(200) := 'TEST Mail for Multiple Attachment';
    /* This send_header procedure is written in the documentation */
    PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
    BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    pi_name || ': ' || pi_header || UTL_TCP.CRLF);
    END;
    BEGIN
    /*Preparing the LOB from file for attachment01. */
    DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
    v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
    l_blob_len := DBMS_LOB.getlength(l_blob);
    /*Preparing the LOB from file for attachment02. */
    DBMS_LOB.OPEN(v_src_loc2, DBMS_LOB.LOB_READONLY); --Read the file
    DBMS_LOB.CREATETEMPORARY(l_blob2, TRUE); --Create temporary LOB to store the file.
    v_amount2 := DBMS_LOB.GETLENGTH(v_src_loc2); --Amount to store.
    DBMS_LOB.LOADFROMFILE(l_blob2, v_src_loc2, v_amount2); -- Loading from file into temporary LOB
    l_blob_len2 := DBMS_LOB.getlength(l_blob2);
    /*UTL_SMTP related coding. */
    v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
    UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
    UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
    UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
    UTL_SMTP.OPEN_DATA(v_connection_handle);
    send_header('From', '"Sender"');
    send_header('To', '"Recipient"');
    send_header('Subject', v_subject);
    --MIME header.
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'MIME-Version: 1.0' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Body
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: text/plain;' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' charset=US-ASCII' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment01
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos := l_pos + l_amount;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Mail Attachment02
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Type: application/octet-stream' ||
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    ' filename="' || 'export1.log' || '"' || --My filename
    UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    /* Writing the BLOL in chunks */
    WHILE l_pos2 < l_blob_len2 LOOP
    DBMS_LOB.READ(l_blob2, l_amount2, l_pos2, l_buffer2);
    UTL_SMTP.write_raw_data(v_connection_handle,
    UTL_ENCODE.BASE64_ENCODE(l_buffer2));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer2 := NULL;
    l_pos2 := l_pos2 + l_amount2;
    END LOOP;
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    -- Close Email
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
    UTL_SMTP.WRITE_DATA(v_connection_handle,
    UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
    UTL_SMTP.CLOSE_DATA(v_connection_handle);
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    DBMS_LOB.FREETEMPORARY(l_blob2);
    DBMS_LOB.FILECLOSE(v_src_loc2);
    RAISE;
    END;
    PL/SQL procedure successfully completed.
    Edited by: SHAN2009 on May 11, 2011 1:05 PM

  • How to display an URL in a UTL_SMTP email in a package.

    Hi all, I tried to display this uRL from a text line in a email i send out.
    lv_message :=
                lv_message
             || 'ABCDEFGHIJKLM'
             || lv_bss_siteid_notin_lkup;
          lv_message := lv_message || gv_crlf;
          lv_message := lv_message || gv_crlf;
          lv_message := lv_message || gv_crlf;
          lv_message := lv_message || gv_crlf;This error popss up
    Error(1368,13): PLS-00103: Encountered the symbol "<" when expecting one of the following: ( - + case mod new null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternatively-quoted SQL string>
    Message was edited by:
    CrackerJack

    Hi Billy,
    I grabbed this procedure from metalink.But it does not work.
    CREATE OR REPLACE PROCEDURE sp_batch_email_test
    IS
        mailhost VARCHAR2 (30) := 'smtp.company.com';
        mail_conn utl_smtp.connection;
        crlf VARCHAR2(2) := CHR (13) || CHR (10);
        message_1 LONG;
        v_email varchar2(16000);
    BEGIN
        mail_conn := utl_smtp.open_connection (mailhost, 25);
        utl_smtp.helo (mail_conn, mailhost);
        utl_smtp.mail (mail_conn, '[email protected]');
        utl_smtp.rcpt (mail_conn, '[email protected]');
          message_1 := 'From: Mr Sender < [email protected] >' || crlf ||
             'Subject: Testing Hyperlink' || crlf ||
             'To: Mrs Receiver <[email protected]>' || crlf || '
    || crlf || crlf ;
    utl_smtp.data(mail_conn, 'MIME-Version: 1.0' ||CHR(13)||
    CHR(10)||'Content-type: text/html' || CHR(13)||CHR(10)||message_1);
    utl_smtp.quit (mail_conn);
    END;
    I tried incorporating || 'ABCDEFGHIJKLM' but it displayed as literal and not as a hyperlink.
    Any idea on howto programmatically through PL/SQL send an email which will allow a hyperlink to be created?
    Please click edit to see teh codes.Really appreciate if someone could throw some light into this.
    I don't why that URL is not displaying in the procedure...grr
    Message was edited by:
    CrackerJack

  • Sending e-mail using utl_smtp on oracle 9i

    Hello
    I have problem with sending e-mails using utl_smtp package.
    My code looks like this:
    lv_mail_conn := utl_smtp.open_connection(lv_mailhost_txt);
    utl_smtp.ehlo(lv_mail_conn, lv_mailhost_txt);
    res :=     utl_smtp.command(lv_mail_conn, 'AUTH LOGIN');
    res := utl_smtp.command(lv_mail_conn, <login in base64>);
    res := utl_smtp.command(lv_mail_conn, <password in base64>);
    And I get en error after sending a password to SMTP server.
    Error code: 535, text: 5.7.3 Authentication unsuccessful.
    This happens on oracle 9i.
    I have another server for testing which has oracle 10g installed. This code works fine on oracle 10g but doesn't work on oracle 9i.
    Do you have any ideas what's wrong? I assume that SMTP server (microsoft exchange) work correctlys because I can send e-mail from test server.

    Ok problem solved :)
    Problem was between oracle and MS exchange server. Live server oracle 9i is on linux, and testing server works on windows.
    So the problem was with configuration. Our admins corrected it and now works :). I don't know details.

  • Error while using utl_smtp,pls help

    CREATE OR REPLACE PROCEDURE send_mail (p_sender IN VARCHAR2,
    p_recipient IN VARCHAR2,
    p_message IN VARCHAR2)
    as
    l_mailhost VARCHAR2(255) := '10.16.56.30';
    l_mail_conn utl_smtp.connection;
    BEGIN
    l_mail_conn := utl_smtp.open_connection(l_mailhost, 25);
    utl_smtp.helo(l_mail_conn, l_mailhost);
    utl_smtp.mail(l_mail_conn, p_sender);
    utl_smtp.rcpt(l_mail_conn, p_recipient);
    utl_smtp.open_data(l_mail_conn );
    utl_smtp.write_data(l_mail_conn, p_message);
    utl_smtp.close_data(l_mail_conn );
    utl_smtp.quit(l_mail_conn);
    end;
    i create dthe above and when i am running it i am getting the following error
    SQL> execute send_mail('[email protected]','[email protected]','hi');
    BEGIN send_mail('[email protected]','[email protected]','hi'); END;
    ERROR at line 1:
    ORA-29278: SMTP transient error: 450 4.7.1 [email protected]..
    Relaying temporarily denied. Cannot resolve PTR record for 10.16.56.20
    ORA-06512: at "SYS.UTL_SMTP", line 17
    ORA-06512: at "SYS.UTL_SMTP", line 96
    ORA-06512: at "SYS.UTL_SMTP", line 240
    ORA-06512: at "TTK05.SEND_MAIL", line 11
    ORA-06512: at line 1
    pls help me , i need to send a mail from the above
    reg

    Hi,
    try to use the host-name instead of the IP and check your dns configuration (Cannot resolve PTR record for 10.16.56.20).
    (Relaying temporarily denied) -> Some mail-servers are configured to accept only messages for their domain, e.g. mailserver mail.dummy.com only accepts messages to account with name like [email protected]

Maybe you are looking for

  • Help with Powershell script to gather eventlogs from all Domain Controllers

    I am trying to write a script to grab the last 5 days of application, security and system logs from all domain controllers. The script runs but only pulls the logs from the local server. The $Computer variable has all of my DC's so it is querying fin

  • "SYNTAX_ERROR" while creating customer Master T-code-"FD01

    Dear All, Getting an error "SYNTAX_ERROR" while creating customer Master T-code-"FD01". The error as follwoes Short text :Syntax error in program "CMD_EI_API_CHECK==============CP ". What happened? : Error in the ABAP Application Program             

  • Phone does not recognise contacts

    I have a few contacs on my phones address book that my phone just will not recognise when they phone or txt me. Ive tried deleting and re saving the number, syncing to google but it just doesnt seem to remember them. Solved! Go to Solution.

  • Test & Measuremen​t World test idea features LabView

    Dear LabViewers: I want to bring to your attention an article we published today called "Genrate a swept sine in LabView" by Sean McPeak of UC San Diego. For the last several months, we've been running the Test Dieas column by hijacking stories submi

  • Working with EXCEL and WORD files on a Mac Pro

    Hello, I have a lot of EXCEL and WORD files and the compatibility with NUMBERS and PAGES is not really satisfying. Is there a EXCEL and WORD app which runs without surprises on a Mac Pro?