As a developer, you might have encountered a situation where client needed error or warning messages after certain programs are executed. Monitoring program continuously will be obviously waste of hours for them. So they demand automatic mails to be delivered to them whenever programs goes in error or warning. This requirement can be fulfilled in PL/SQL using UTL_MAIL and UTL_SMTP packages. SMTP (Simple Mail Transfer Protocol) is used by both to transmit mails over the network.
To help you in deciding which one to use, below are the differences between UTL_MAIL and UTL_SMTP
|Introduced in Oracle 10g and thereafter||Introduced in Oracle 8i and thereafter|
|Easier to use as compared to UTL_SMTP||Older version and require some knowledge of SMTP|
|Requires parameter SMTP_OUT_SERVER to get initialized in init.ora file||Does not require any initialization parameter|
|Does not require SMTP connection to be opened explicitly||Requires SMTP connection to be opened explicitly inside the package
UTL_SMTP.OPEN_CONNECTION(host => 'smtp.google.com', port => 465);
|Message priority can be defined||Message priority cannot be defined|
|Host and Port are not required to be passed in code||Host and Port are required to be passed in code|
|You can define MIME Type of attachment. Default is 'text/plain; charset=us-ascii'||MIME Type cannot be defined|
|Does not requires explicit handshake||Requires handshake with SMTP server
UTL_MAIL and UTL_SMTP both are good except UTL_MAIL is much simpler to configure than UTL_SMTP. You can check your Oracle database version in which your application is running. Choice should be definitely UTL_MAIL if your database version is 10g and above.
To err is human, so if I have missed any points, please mention them in comments. I will incorporate it in this difference table. If you liked this post then drop comments of appreciation.
Put your comments below if you liked this post. Your feedback and suggestions are valuable to us.
Did you enjoy this post? Then subscribe here and help me to deliver oracle technology related articles in more interesting way.
Hi I am Paras.
Thanks for stopping by at OracleMine.com. Speaking about my brief introduction, I work for a multinational organisation in Oracle related technologies. Being an avid blogger, I would like to inform you about my productivity and motivational blog XpressPlanet.com. Speaking of OracleMine.com, I will try my best to share knowledge on technologies in as simple and understandable manner as possible. You can also contribute your knowledge on OracleMine by writing to us at firstname.lastname@example.org. Again I appreciate your visit. Hope to see you again and again!