Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Rebecca .

Asked: January 05, 2005 - 8:49 pm UTC

Last updated: January 23, 2019 - 3:52 am UTC

Version: 9.2.0.4.0

Viewed 1000+ times

You Asked

Hi there,

I am trying to use utl_smtp to send out email to our customers. How can we tell is the email successful delivered ? Does reply code indicate the successful of delivery ? Below is a testing procedure I had created. I got the same result on the reply code (250) whenever I send a valid email address or a dummy email address. Can you help me on this

CREATE OR REPLACE PROCEDURE SimpleTextMessage1 IS
mailHOST VARCHAR2(64) := 'mailhost.mydomain.com';
mailFROM VARCHAR2(64);
mailTO VARCHAR2(64);
mailCONN utl_smtp.connection;
mailDATE VARCHAR2(20);
vreply utl_smtp.reply;

BEGIN
mailFROM := 'test@mydomain.com';
mailTO := 'dummytestwo@yahoo.com';
SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;


vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);

dbms_output.put_line('mail');
dbms_output.put_line('----');
vreply := utl_smtp.mail(mailCONN, mailFROM);
dbms_output.put_line( 'code = ' || vreply.code );
dbms_output.put_line( 'text = ' || vreply.text );

vreply := utl_smtp.rcpt(mailCONN, mailTO);
dbms_output.put_line('mailto');
dbms_output.put_line('----');
dbms_output.put_line( 'code = ' || vreply.code );
dbms_output.put_line( 'text = ' || vreply.text );


vreply := utl_smtp.open_data(mailCONN);
dbms_output.put_line('open_data');
dbms_output.put_line('----');
dbms_output.put_line( 'code = ' || vreply.code );
dbms_output.put_line( 'text = ' || vreply.text );

utl_smtp.write_data(mailCONN, 'Subject: '|| 'A subject' || chr(13));


utl_smtp.write_data(mailCONN, 'From: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, 'Date: '||mailDATE || chr(13));
utl_smtp.write_data(mailCONN, 'To: '||mailTO || chr(13));
utl_smtp.write_data(mailCONN, 'CC: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, 'BCC: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, chr(13));
utl_smtp.write_data(mailCONN, 'Hello Friend.' || chr(13));
utl_smtp.write_data(mailCONN, 'Drop me an e-mail.' || chr(13));



vreply := utl_smtp.close_data(mailCONN);
dbms_output.put_line('close_data');
dbms_output.put_line('----');
dbms_output.put_line( 'code = ' || vreply.code );
dbms_output.put_line( 'text = ' || vreply.text );


vreply := utl_smtp.quit(mailCONN);

dbms_output.put_line('done');
dbms_output.put_line('----');
dbms_output.put_line( 'code = ' || vreply.code );
dbms_output.put_line( 'text = ' || vreply.text );


END;
/


Thanks,
Rebecca


and Tom said...

the only thing you can tell with SMTP is that your mail was successfully "queued".

The mail will bounce back via email if it cannot ultimately be delivered.


It is just like sending email from your email program -- you could send an email to "no_one@no.where.com" and it would "send"

it would however bounce back.


So, you need to monitor the mailbox it bounces back to in order to see if it was "sent"



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

UTL_STMP used in Oracle Concurrent Program

A reader, January 22, 2019 - 9:47 pm UTC

Hi Tom,

I have a plsql procedure using UTL_STMP to run on every Sunday and it got scheduled through oracle concurrent request.

Recently we cancelled the scheduler job but even though we are receiving the email on every Sunday.

I'm not sure from where the email is getting triggered. Because I cancelled the scheduler job and also I disabled the concurrent program in Oracle.

But I am receiving the email with 0kb file as attachment

Please advise how to stop this email

Thanks,
Connor McDonald
January 23, 2019 - 3:52 am UTC

Why not just drop the PL/SQL procedure ?

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library