Re: Can't email using utl_smtp

From: Paul Dixon <antispam_at_bt.com>
Date: Tue, 3 Jun 2003 13:09:03 +0100
Message-ID: <bbi3je$lv1$1_at_pheidippides.axion.bt.co.uk>


[Quoted] "Pavel Vetesnik" <Pavel.Vet_at_volny.cz> wrote in message news:bbhk60$m7g$1_at_ns.felk.cvut.cz...
> Hello,
>
> I tried to send emails using utl_smtp package (on Oracle 8i), but I was
not
> succesfull.

Pavel,

I've had trouble getting this to work myself.

I didn't see anything wrong with your code, however I've taken values from your code and put them into a test package that definitely works on my server (Oracle 8.1.7.4). Try running my code with dbms_output switched on and check the responses you get. It's possible your mailserver just doesn't [Quoted] like the values your sending it and the replies it gives could point you in the right direction.

Paul Dixon



[Quoted] CREATE OR REPLACE PACKAGE BODY pkg_email AS PROCEDURE send (p_sender_name IN VARCHAR2,
p_sender_smtp IN VARCHAR2,
p_domain IN VARCHAR2,
p_recipient_name IN VARCHAR2,
p_recipient_smtp IN VARCHAR2,
p_message IN VARCHAR2,
p_subject IN VARCHAR2 )

IS
mail_conn utl_smtp.connection;
reply utl_smtp.reply;
BEGIN
reply := utl_smtp.open_connection ('jupiter.stk.cz', 25, mail_conn); DBMS_OUTPUT.PUT_LINE('mail connection IS '|| mail_conn.host||
' port '||
TO_CHAR(mail_conn.port)||
' message IS : '||
reply.text);
reply := utl_smtp.helo (mail_conn, p_domain); DBMS_OUTPUT.PUT_LINE('domain IS '||
p_domain||
' message IS : '||
reply.text);
reply := utl_smtp.mail (mail_conn, p_sender_smtp); DBMS_OUTPUT.PUT_LINE('sender IS '||
p_sender_smtp||
' message IS : '||
reply.text);
reply := utl_smtp.rcpt (mail_conn, p_recipient_smtp); DBMS_OUTPUT.PUT_LINE('recipient IS '||
p_recipient_smtp||
' message IS : '||
reply.text);
reply := utl_smtp.open_data(mail_conn);
DBMS_OUTPUT.PUT_LINE('open_data response message IS : '|| reply.text);
utl_smtp.write_data(mail_conn,'From: "'||p_sender_name||'" <'||p_sender_smtp||'>'||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,'To: "'||p_recipient_name||'" <'||p_recipient_smtp||'>'||utl_tcp.crlf); utl_smtp.write_data(mail_conn,'Subject: '||p_subject||utl_tcp.crlf); utl_smtp.write_data(mail_conn,utl_tcp.crlf||p_message); reply := utl_smtp.close_data (mail_conn); DBMS_OUTPUT.PUT_LINE('response TO sent message IS : '|| reply.text);
utl_smtp.quit (mail_conn);
END send;

PROCEDURE mail_event IS
BEGIN
send('Pavel Vetesnik',

'pavel.vet_at_volny.cz',
'jupiter.stk.cz',
'Pavel Vetesnik',
'P.Vetesnik_at_stk.cz',
'This is just for test.....',
'Testing');

END mail_event;
END pkg_email; Received on Tue Jun 03 2003 - 14:09:03 CEST

Original text of this message