tags:

views:

219

answers:

2

I have created a Oracle function to send an email using the UTL_SMTP package.

When using the methods Write_Data or Data, if my text does not contain a colon, the sent email will contain the inputted text in the email's body.

However, if the text contains a colon, the text is not included in the email.

Every example of this i've seen online seems to indicate this is no problem. Any idea what could be the cause of this?

This works: UTL_SMTP.write_data(l_mail_conn, 'test');

This does not get sent: UTL_SMTP.write_data(l_mail_conn, 'test:');

nor does: UTL_SMTP.write_data(l_mail_conn, 'test' || ':');

+1  A: 

It may be getting interpreted as a header

Rather than write your own, look at the mail code included in PLCODEBREW

Gary
I'm pretty sure this is the cause. After the "real" headers, add a blank line - `UTL_SMTP.write_data(l_main_conn, '')`
Jeffrey Kemp
Not having any luck with the blank line; still refuses to send any text following that with a colon. Gonna give it a try with the UTL_MAIL.
abbott
UTL_MAIL package works like a charm. What's the proper way to handle this within the context of the post?
abbott
Stick your own answer in about UTL_MAIL and mark it correct. That will be the more useful answer for future viewers
Gary
A: 

I wasn't able to get UTL_SMTP working - certainly looks like any colons in the UTL_SMTP body was being interpreted as a header and I could not find a way to escape them.

I was able to use the UTL_MAIL package introduced by Oracle in 10g and it worked very well. Only configuration necessary was setting the smtp_out_server variable in oracle to the mail server (include the port number)of the mail server. Only requires a single method call - much cleaner to implement in PL/SQL as well - and also allows you more control over specific email fields (Subject, for example) and can handle attachments as well.

abbott