Email Body Is Sometimes Truncated When Sent Via UTL_SMTP (Doc ID 376690.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version: 9.2.0.5
This problem can occur on any platform.

Symptoms

The following anonymous block sends e-mail and illustrates text within an e-mail that will either be missing or result in truncation.
There are a number of messages commented out but available for testing. One message works while the others will be missing or truncated. When testing the code, the different e-mail messages can be commented and uncommented to see the behavior.

--Don't forget to add the e-mail host and e-mail addresses to the code before executing.

DECLARE
   P_SUBJECT VARCHAR2(200);
   P_ERROR_MSG VARCHAR2(200);
   L_MAICON UTL_SMTP.CONNECTION;
   L_MAILHOST VARCHAR2(255) := 'your email host';
   L_SENDER VARCHAR2(255) := 'your email address';
   L_RECVR VARCHAR2(255) := 'your email address';
BEGIN
P_SUBJECT := 'Some kind of subject';
-----------------------------------------------------------------------------------------------------------
-- this message body works --
--P_ERROR_MSG := 'Message ORA-20003: Some kind of error description: ORA-01427: Underlying error description';

-- the following message bodies are all truncated --
--P_ERROR_MSG := 'Message: ORA-20003: Some kind of error description: ORA-01427: Underlying error description';
--P_ERROR_MSG := ' : ORA-20003: Some kind of error description: ORA-01427: Underlying error description';
--P_ERROR_MSG := ' ORA-20003: Some kind of error description: ORA-01427: Underlying error description';
P_ERROR_MSG := 'ORA-20003: Some kind of error description: ORA-01427: Underlying error description';
-----------------------------------------------------------------------------------------------------------
L_MAICON :=UTL_SMTP.OPEN_CONNECTION(L_MAILHOST, 25);
   UTL_SMTP.HELO(L_MAICON,L_MAILHOST);
   UTL_SMTP.MAIL(L_MAICON,L_SENDER);
   UTL_SMTP.RCPT(L_MAICON,L_RECVR);
   UTL_SMTP.OPEN_DATA(L_MAICON);
   UTL_SMTP.WRITE_DATA(L_MAICON,'FROM: '|| L_SENDER || UTL_TCP.CRLF);
   UTL_SMTP.WRITE_DATA(L_MAICON,'TO: '|| L_RECVR || UTL_TCP.CRLF);
   UTL_SMTP.WRITE_DATA(L_MAICON,'SUBJECT: ' || P_SUBJECT || UTL_TCP.CRLF);
   UTL_SMTP.WRITE_DATA(L_MAICON,'X-Priority: ' || '1' || UTL_TCP.CRLF);
   UTL_SMTP.WRITE_DATA(L_MAICON, P_ERROR_MSG);
   UTL_SMTP.CLOSE_DATA(L_MAICON);
   UTL_SMTP.QUIT(L_MAICON);
END EMAIL_NOTIFICATION;
/

 

With the above sample, the lines starting with a WORD||COLON or WHITE SPACE COLON get either truncated or will have no text displayed.

Also a line like   "P_ERROR_MSG := 'Monkeyshine: Underlying error description'; "  fails as well as the others shown.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms