Try this one:

create or replace PROCEDURE send2 
(sender IN VARCHAR2, 
recipient IN VARCHAR2, 
subj IN VARCHAR2,
body IN VARCHAR2) 
crlf VARCHAR2(2):= CHR( 13 ) || CHR( 10 );
mesg VARCHAR2(4000);
mail_conn UTL_SMTP.CONNECTION;
cc_recipient VARCHAR2(50) default '[EMAIL PROTECTED]';
bcc_recipient VARCHAR2(50) default '[EMAIL PROTECTED]'; 
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.rcpt(mail_conn, cc_recipient); 
utl_smtp.rcpt(mail_conn, bcc_recipient); 
mesg:= 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
'From: ' || sender || crlf ||
'To: ' || recipient || crlf ||
'Cc: ' || cc_recipient || crlf ||
'Bcc: ' || bcc_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; 
/ 

Arno
-----Original Message-----
Sent: Wednesday, July 04, 2001 1:01 PM
To: Multiple recipients of list ORACLE-L


Hi Gurus,

I am trying to used UTL_SMTP to send an e-mail form my oracle machine. I
tried the sample code from oracle documentation.

PROCEDURE send_mail (sender    IN VARCHAR2,
                                       recipient IN VARCHAR2,
                                       message   IN VARCHAR2)
as
    mailhost    VARCHAR2(30) := 'mail.somewhere.com';
    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.data(mail_conn, message);
    utl_smtp.quit(mail_conn);
EXCEPTION
    WHEN OTHERS THEN
        dbms_output.put_line('error');
        -- Handle the error
END;

and i call the procedure from sqlplus


begin
send_mail('[EMAIL PROTECTED]','[EMAIL PROTECTED]','test from oracle');
end;


and i receive the e-mail like this


Return-Path: <[EMAIL PROTECTED]> 
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 3139 invoked from network); 4 Jul 2001 09:58:00 -0000 
Received: from oracle.somewhere.com (HELO mail.somewhere.com) (192.169.0.25)

by mail.somewhere.com with SMTP; 4 Jul 2001 09:58:01 -0000 
X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) 

test form oracle


the problem is i lost the sender ( it sould be [EMAIL PROTECTED]) and the
title (i don't know where i must put the title).

Regards,

Herman
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Disser, Arno
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to