Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email. (文档 ID 604763.1) | 转到底部 |
修改时间:2014-5-13类型:PROBLEM |
|
In this Document
APPLIES TO:PL/SQL - Version 9.2.0.8 and later SYMPTOMSWhen trying to send email using UTL_SMTP getting following error : ORA-29278: SMTP transient error: 421 Service not available Or potentially ORA-29279: SMTP permanent error followed by a SMTP error code. CAUSEThe "ORA-29278: SMTP transient error: 421 Service not available" error indicates that the problem is not with the UTL_SMTP package SOLUTIONYou 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 should open with a response from smtp: For eg : response from smtp ---> 220 ukxxx1 Sendmail SMI-8.6/SMI-SVR4 ready at b) Now introduce the client machine to the server by typing: c) Tell the SMTP Gateway who the test email is coming from by typing: 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: 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: 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 "." A response from smtp ---> 250 PAA15913 Message accepted for delivery g) End the SMTP connection session by typing: response from smtp ---> 221 ukxxx1 closing connection The email should then be delivered to the receiver 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. 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. CREATE OR REPLACE PROCEDURE TESTMAIL(fromm VARCHAR2,too VARCHAR2,sub VARCHAR2,body VARCHAR2,port NUMBER) UTL_SMTP.WRITE_DATA(objConnection, ‘From: ‘||fromm || UTL_TCP.CRLF); UTL_SMTP.WRITE_DATA(objConnection, ‘Subject: ‘ || sub || UTL_tcp.CRLF); UTL_SMTP.WRITE_DATA(objConnection, ‘Content-Transfer-Encoding: ‘ || ‘"8Bit"‘ || UTL_TCP.CRLF); DECLARE Collaborate with and learn from your Peers, Industry Experts and Oracle Support Product Specialists using My Oracle Support Community. Join us here: Oracle Community - https://communities.oracle.com/ Oracle PL/SQL Community - https://community.oracle.com/community/support/oracle_database/pl_sql REFERENCESNOTE:74269.1 - How to Test an SMTP Mail Gateway From a Command Line Interface |