Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: problem in procedure to send email via plsql procedure
ganesh bora wrote:
> Hi all I wrote a procedure to send email via plsql procedure, It was
> compiled sucessfully but not working ....
>
> here is the code (actuly i added the dbms output like step1 ,step 2 to
> see in which step the control is going on )
>
> create or replace PROCEDURE send_test_message
> IS
> mailhost VARCHAR2(64) := 'gmail.com';
> sender VARCHAR2(64) := 'avc_at_gmail.com';
> recipient VARCHAR2(64) := 'djdjjdd_at_gmail.com';
> mail_conn utl_smtp.connection;
> BEGIN
> dbms_output.put_line('Step:1');
> mail_conn := utl_smtp.open_connection(mailhost, 25);
> dbms_output.put_line('Step:2');
> utl_smtp.helo(mail_conn, mailhost);
> dbms_output.put_line('Step:3');
> utl_smtp.mail(mail_conn, sender);
> dbms_output.put_line('Step:4');
> utl_smtp.rcpt(mail_conn, recipient);
> dbms_output.put_line('Step:5');
> -- If we had the message in a single string, we could collapse
> -- open_data(), write_data(), and close_data() into a single call to
> data().
> utl_smtp.open_data(mail_conn);
> dbms_output.put_line('Step:6');
> utl_smtp.write_data(mail_conn, 'This is a test message.' || chr(13));
> dbms_output.put_line('Step:7');
> utl_smtp.write_data(mail_conn, 'This is line 2.' || chr(13));
> dbms_output.put_line('Step:8');
> utl_smtp.close_data(mail_conn);
> dbms_output.put_line('Step:9');
> dbms_output.put_line('Step:10');
> utl_smtp.quit(mail_conn);
> dbms_output.put_line('Step:11');
> EXCEPTION
> WHEN OTHERS THEN
> dbms_output.put_line('not executed i m in exeption ');
> END;
> /
>
> SQL> exec send_test_message
> Step:1
> Step:2
> Step:3
> Step:4
> not executed i m in exeption
>
> plz give sum advise what i m doing wrong
>
> thanks
Since you got to step 4 and not to step 5, you obviously failed on the statement:
utl_smtp.rcpt(mail_conn, recipient);
Read up some more on utl_smtp.rcpt. Find out what kind of errors it can throw. Modify your EXCEPTION section to be a bit more informative of why you got there. Received on Tue Jan 23 2007 - 09:02:19 CST
![]() |
![]() |