Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UTL_SMTP Recipient Invalid --Catch Exception

820364Jan 21 2011 — edited Jan 21 2011
Hello Folks!
I am using UTL_SMTP to send emails. below is my code snippet..I see that the when i give invalid recipient email address(syntax OK but email doesn't exists in the domain) like 'xxx@domain.com'. My program is successfully completing even though i have transient_error and permanent_error exception handled. Can any one suggest me of how to catch such exception where syntax for the email address is correct however such email doesn't exist in the domain. Also is there a way i can have delivery status to know the email has been sent so that i can update the records to be processed in the Db tables.
.....
......
objConnection := UTL_SMTP.OPEN_CONNECTION('smtp.xxx.com',25);
UTL_SMTP.HELO(objConnection, 'xxx.com');
UTL_SMTP.MAIL(objConnection, P_from_i);
UTL_SMTP.RCPT(objConnection, p_to_i);
UTL_SMTP.OPEN_DATA(objConnection);

UTL_SMTP.WRITE_DATA(objConnection, 'From: '||P_from_i || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(objConnection, 'To: '||p_to_i || UTL_TCP.CRLF);

UTL_SMTP.WRITE_DATA(objConnection, 'Subject: '||'Hi'|| UTL_tcp.CRLF);
UTL_SMTP.WRITE_DATA(objConnection, 'MIME-Version: ' || '1.0' || UTL_tcp.CRLF);
UTL_SMTP.WRITE_DATA(objConnection, 'Content-Type: ' || 'text/html;');

UTL_SMTP.WRITE_DATA(objConnection, 'Content-Transfer-Encoding: ' || '"8Bit"' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF||'<HTML>');
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF||'<BODY>');
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF||'<FONT COLOR="red" FACE="Courier New">'||P_body_i||'As on : '||'</FONT>');
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF||'</BODY>');
UTL_SMTP.WRITE_DATA(objConnection,UTL_TCP.CRLF||'</HTML>');
UTL_SMTP.CLOSE_DATA(objConnection);
UTL_SMTP.QUIT(objConnection);

EXCEPTION
WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
UTL_SMTP.QUIT(objConnection);

FND_FILE.put_line(FND_FILE.output,'Exception Mail Block: '||SQLERRM);
WHEN
OTHERS THEN
UTL_SMTP.QUIT(objconnection);
FND_FILE.put_line(FND_FILE.output,'Exception Mail Block2: '||SQLERRM);
END;

Edited by: user8914785 on Jan 21, 2011 12:39 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2011
Added on Jan 21 2011
3 comments
1,612 views