Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UTL_SMTP Error

636387Sep 14 2009 — edited Sep 15 2009
Hi,

I want to send the MAIL(to gmail or yahoo) via PL/SQL code for that i am using the following code............
DECLARE
  v_From      VARCHAR2(80) := 'anyname@gmail.com';
  v_Recipient VARCHAR2(80) := 'anyname@gmail.com';
  v_Subject   VARCHAR2(80) := 'ERROR';
  v_Mail_Host VARCHAR2(30) := 'smtp.gmail.com';
  v_Mail_Conn utl_smtp.Connection;
  crlf        VARCHAR2(2)  := chr(13)||chr(10);
BEGIN
 v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host,465);
 utl_smtp.helo(v_Mail_Conn,v_Mail_Host);     
utl_smtp.command( v_Mail_Conn, 'AUTH LOGIN');
utl_smtp.command( v_Mail_Conn, utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw('YW55bmFtZUBnbWFpbC5jb20==='))));
utl_smtp.command(v_Mail_Conn , utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw('YW55bmFtZQ===' ))));
--utl_smtp.mail(v_mail_conn,sender); 
 utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
 utl_smtp.Mail(v_Mail_Conn, v_From);
 utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
 utl_smtp.Data(v_Mail_Conn,
   'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || utl_tcp.crlf ||
   'From: '   || v_From || utl_tcp.crlf ||
   'Subject: '|| v_Subject || utl_tcp.crlf ||
   'To: '     || v_Recipient || utl_tcp.crlf ||   utl_tcp.crlf ||
   'some error while executing plz look into the issue'|| utl_tcp.crlf ||	
   'Thanks and Regards'|| utl_tcp.crlf
   
 );
 utl_smtp.Quit(v_mail_conn);
EXCEPTION
 WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
   raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
but here i am getting the following error........ can any one help me
ORA-29278: SMTP transient error: string 421  service not available 
Thanks
SKPR
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2009
Added on Sep 14 2009
14 comments
2,009 views