Skip to Main Content
  • Questions
  • UTL_SMTP not sending email consistently


Dev Live Dev Intro

This month we are celebrating Developers at AskTOM. We welcome Developers of all levels of experience to join us at our FREE Developer Live events coming in August. Just click on the left to register today! If you are brand new to Database Technology, then we also have got you covered. Just click on the right for your comprehensive FREE training program to kick start your Oracle Database Development journey!

Question and Answer

Chris Saxon

Thanks for the question, Arun.

Asked: January 14, 2020 - 5:31 am UTC

Answered by: Chris Saxon - Last updated: January 14, 2020 - 5:19 pm UTC

Category: PL/SQL - Version: Oracle DBCS

Viewed 100+ times

You Asked

Hello Experts.

I am facing some issues with sending email from DBCS using UTL_SMTP

My package is as below:


create or replace PROCEDURE send_mail (p_to        IN VARCHAR2,
                                       p_from      IN VARCHAR2,
                                       p_message   IN VARCHAR2,
                                       p_smtp_host IN VARCHAR2,
                                       p_smtp_port IN NUMBER DEFAULT 25)
  l_mail_conn   UTL_SMTP.connection;
  l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
  UTL_SMTP.helo(l_mail_conn, p_smtp_host);
  UTL_SMTP.mail(l_mail_conn, p_from);
  UTL_SMTP.rcpt(l_mail_conn, p_to);, p_message || UTL_TCP.crlf || UTL_TCP.crlf);


Procedure call:

                  'Test Message from SMTP - UAT 4', 


SMTP and ACL is configured on the Database.

When I call this procedure, I get the email, but it is inconsistent.
If I make the same procedure call 10 times, for example, I get email 5-6 times.
The remaining 4 times I don't get any email.

This is causing issues for me in many UAT code packages as emails are not sent consistently.

Can you please advise what I need to check.
Doesn't seem to be a code issue to me as I do get emails a few times.

Thanks in advance for your time.


and we said...

It's possible that there's an issue with the network and/or the email server. Or the mail server may have rules in place to throttle traffic if it gets lots of messages with the same from/to addresses.

So work with your network and email server admins to see if the requests are making it to the mail server.

If the mails aren't making it to the mail server, add logging to your code to verify all the steps are working.

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

More to Explore


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