Check SMTP server availability for ORA-29278 or ORA-29279 errors using utl_smtp to send email

Source: Internet
Author: User
Check SMTP server availability for ORA-29278 or ORA-29279 errors using utl_smtp to send email. (Document ID 604763.1) Go to the bottom
Modification time:Type:Problem
Rating this document Send a link to this document via email Open a document in a new window

In this document



Applies to: PL/SQL-version and later
Information in this document applies to any platform.
* ** Checked for relevance on 13-may-2014 ***

When trying to send email using utl_smtp getting following error:

ORA-29278: SMTP transient error: 421 service not available
ORA-06512: At "SYS. utl_smtp", line 21
ORA-06512: At "SYS. utl_smtp", line 97
ORA-06512: At "SYS. utl_smtp", line 139

Or potentially

ORA-29279: SMTP permanent error

Followed by a SMTP error code.


The "ORA-29278: SMTP transient error: 421 service not available" error indicates that the problem is not with the utl_smtp package
But the fact that your database server's network configuration does not allow it to contact an external server.


You first have to check whether you are able to contact the email server without involving oracle.

For example use the following Telnet procedure to see whether the mail server is reachable from the database server:

* ***** Perform the following operations from your database server machine and not from other machines .******

Note: The information presented here does not apply to TLS/SSL connections.


A) Start a telnet session to the SMTP server's communication port. (the default port for SMTP is 25)

$ Telnet <SMTP servername as used utl_smtp package> 25

A telnet session shoshould open with a response from SMTP:

For eg:

Response from SMTP ---> 220 ukxxx1 Sendmail SMI-8.6/SMI-SVR4 ready
Thu, 16 Sep 1999 15:14:25 + 0100

B) now introduce the client machine to the server by typing:
Helo domain
(The correct spelling is helo-Not hello)

C) Tell the SMTP gateway who the test email is coming from typing:
-------> Mail from: [email protected]

For eg:

A response from SMTP ---> 250 [email protected] sender OK

D) Tell the SMTP gateway who to send the test email to by typing:
--------> Rcpt to: [email protected]

For eg:

A response from SMTP ---> 250 [email protected] recipient OK

E) Tell the SMTP gateway what type of information is being sent by typing:
-------> Data

A response from SMTP ---> 354 enter mail, end with "." on a line by itself

F) enter the Test message and remember to close the email with a dot "."
Type ---> subject: SMTP Test
Hello this is an SMTP test for Em ..

A response from SMTP --- & gt; 250 paa15913 message accepted for delivery

G) End the SMTP connection session by typing:
--------> Quit

Response from SMTP ---> 221 ukxxx1 closing connection
The connection has been terminated.

The email shoshould then be delivered to the caller via the SMTP server.

If the command line test doesn't work, hopefully a helpful error messages from the SMTP server will be displayed indicating a problem will be with the SMTP server setup.

If the above Telnet session fails it confirms the network block. You may have to contact your network administrator to remove the block.
Once your network administrator removes the block, retry the above Telnet session.
Before using utl_smtp, please ensure that the telnet session succeeds.

If the telnet session succeeds, then try the following sample code to test the SMTP server:

Note: Please change the SMTP server name in line number 6 and 7 in procedure testmail.

Note: If the below Code fails again with the same error, then use IP address instead of mail server name in line number 6 and 7.
Make the hostname entry in the/etc/hosts file so that it is properly resolved to an IP address



Create or replace procedure testmail (Fromm varchar2, too varchar2, sub varchar2, body varchar2, port number)
Objconnection utl_smtp.connection;
Vrdata varchar2 (32000 );
Objconnection: = utl_smtp.open_connection ('<user SMTP server name or IP address>', Port );
Utl_smtp.helo (objconnection, '<user SMTP server name or IP address> ');
Utl_smtp.mail (objconnection, Fromm );
Utl_smtp.rcpt (objconnection, too );
Utl_smtp.open_data (objconnection );

Utl_smtp.write_data (objconnection, 'From: '| Fromm | utl_tcp.crlf );
Utl_smtp.write_data (objconnection, 'to: '| too | utl_tcp.crlf );

Utl_smtp.write_data (objconnection, 'subject: '| sub | 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">' | body | '</font> ');
Utl_smtp.write_data (objconnection, utl_tcp.crlf | '</body> ');
Utl_smtp.write_data (objconnection, utl_tcp.crlf | 'Utl_smtp.close_data (objconnection );
Utl_smtp.quit (objconnection );
When utl_smtp.transient_error or utl_smtp.permanent_error then
Utl_smtp.quit (objconnection );
Dbms_output.put_line (sqlerrm );
When others then
Utl_smtp.quit (objconnection );
Dbms_output.put_line (sqlerrm );
End testmail;

Vdate varchar2 (25 );
Vdate: = to_char (sysdate, 'dd-mon-yyyy hh: MI: SS am ');
Testmail ('[email protected]', '[email protected]', 'testmail', 'This is a UTL_SMTP-generated email at' | vdate, 25 );


Collaborate with and learn from your peers, industry experts and Oracle Support product specialists using my Oracle Support community. Join us here:

Oracle community-

Oracle PL/SQL community- SQL

Referencesnote: 74269.1-how to test an SMTP Mail Gateway from a command line interface
Note: 1559609.1-ORA-29278: SMTP transient error: 452 4.4.5 insufficient disk space

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.