Re: ORA-20002: 501 Bad address syntax

From: leo <schumacherfan2003_at_yahoo.com>
Date: 24 Apr 2003 20:23:20 -0700
Message-ID: <79d24144.0304241923.649ff607_at_posting.google.com>


Hi Karsten,
I already looked up Tom's site. Dont think i am doing anything wrong as his tutorial says. He is not accepting queries cz of heavy backlog. Meanwhile i am pasting my code and output for uer reference :-

Code :------
CREATE OR REPLACE PROCEDURE mail
IS
v_connection UTL_SMTP.CONNECTION;
value UTL_SMTP.reply;

PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS BEGIN
UTL_SMTP.write_data(v_connection, name || ': ' || header || utl_tcp.CRLF);
END; BEGIN v_connection := UTL_SMTP.OPEN_CONNECTION('smtp.server',25); dbms_output.put_line('Connection Opened');

dbms_output.put_line('before calling helo'); value := UTL_SMTP.HELO(v_connection,'smtp.server'); dbms_output.put_line('after calling helo'); dbms_output.put_line('code ' || value.code);

dbms_output.put_line('before Sender is set'); value := UTL_SMTP.MAIL(v_connection,'test_at_test.com'); dbms_output.put_line('code ' || value.code); dbms_output.put_line('text ' || value.text);

UTL_SMTP.RCPT(v_connection,'test_at_test.com'); dbms_output.put_line('Recipient Set');

UTL_SMTP.open_data(v_connection);

send_header('From','"Sender" <test_at_test.com>');
send_header('To','"Recipient" <test_at_test.com>');
send_header('Subject','Hello');

UTL_SMTP.write_data(v_connection, UTL_TCP.CRLF || 'Hello, world!'); UTL_SMTP.close_data(v_connection);
dbms_output.put_line('Message body set');

UTL_SMTP.QUIT(v_connection);
dbms_output.put_line('Connection Closed'); END;
/

Output:--------
Connection Opened
before calling helo
after calling helo
code 250
before Sender is set
code 501
text Bad address syntax

Looking forward to hear...

Reagrds,
Leo.

Karsten Farrell <kfarrell_at_belgariad.com> wrote in message news:<MPG.1911b004353ed0fa989755_at_news.la.sbcglobal.net>...
> schumacherfan2003_at_yahoo.com said...
> > Hi,
> >
> > I intend to send a simple smtp mail using the builtin UTL_SMTP package.
> >
> > But i get the following error:-
> > ORA-20002: 501 Bad syntax error
> >
> > Here is my code:-
> > CREATE OR REPLACE PROCEDURE mail
> > IS
> > BEGIN
> > DECLARE
> > v_connection UTL_SMTP.CONNECTION;
> >
> > BEGIN v_connection := UTL_SMTP.OPEN_CONNECTION(<my host here>,25);
> > dbms_output.put_line('Connection Opened');
> >
> > UTL_SMTP.HELO(v_connection,<my host here>);
> > dbms_output.put_line('After calling helo');
> >
> > UTL_SMTP.MAIL(v_connection,'test_at_myhost.com');
> > dbms_output.put_line('Sender set');
> >
> > UTL_SMTP.RCPT(v_connection,'test1_at_myhost.com');
> > dbms_output.put_line('Recipient Set');
> >
> > UTL_SMTP.DATA(v_connection,'Sent From PL/SQL');
> > dbms_output.put_line('Message body set');
> >
> > UTL_SMTP.QUIT(v_connection);
> > dbms_output.put_line('Connection Closed');
> > end;
> > END;
> > /
> >
> > Here is the output:-
> >
> > SQL> exec mail
> > Connection Opened
> > After calling helo
> > BEGIN mail; END;
> >
> > *
> > ERROR at line 1:
> > ORA-20002: 501 Bad address syntax
> > ORA-06512: at "SYS.UTL_SMTP", line 86
> > ORA-06512: at "SYS.UTL_SMTP", line 204
> > ORA-06512: at "ADMIN.MAIL", line 13
> > ORA-06512: at line 1
> >
> >
> > I tried sending mails to my smtp server via java mailing API and i am
> > successful. So i am wondering wat i am doing wrong up there in Oracle.
> > I have JServer enabled, i also ran the initplsj.sql successfully.
> >
> > Please help.
> > Regards,
> > Leo.
> >
> Don't know whether or not you've looked at Tom Kyte's site yet, but he
> has a lengthy discussion of UTL_SMTP ... see (will wrap):
>
> http://asktom.oracle.com/pls/ask/f?p=4950:8:1090762::NO::F4950_P8
> _DISPLAYID,F4950_P8_CRITERIA:255615160805,
>
> or just go to the asktom site and search for utl_smtp. Tom is usually a
> good resource to check when you run into these baffling scenarios.
Received on Fri Apr 25 2003 - 05:23:20 CEST

Original text of this message