Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SMTP Authentication in Oracle Mail using utl_smtp package

 
Prakash Vaidyanathan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a procedure that sends mail from oracle database to specified mail id. But my smtp server needs authentication. Can anyone tell me how to check for authentication using utl_smtp.
The following is the code i am using for sending mails:
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_to varchar2,
msg_subject varchar2,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer;
msg_from varchar2(50) := 'xxx@xxx.com'; -- dummy mail id & will be replaced with correct mail id at time of execution.
mailhost VARCHAR2(30) := 'cgnnt003'; -- local database host

BEGIN
c := utl_smtp.open_connection(mailhost, 25); -- SMTP on port 25
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);

utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || msg_text);
utl_smtp.quit(c);

EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;
/

Thanks
 
Ravikumar Chellaboina
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash,

You need cross check with your Mail admin and add your IP Address in the Mail Server so that you can send mails from your IP. I do not think you can use authentication using this package. For me the above procedure worked.

Good Luck
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic