Create the procedure below in sqlplus. Replace smtpout.kenyadba.com with your mail server.
CREATE OR REPLACE PROCEDURE kenyadba_send_mail (
mysender VARCHAR2,
myreceiver VARCHAR2,
mysubject VARCHAR2,
mymessage VARCHAR2) IS
mailserver CONSTANT VARCHAR2(30) := 'smtpout.kenyadba.com';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
themessage VARCHAR2(1000);
mail_conn utl_smtp.connection;
BEGIN
mail_conn := utl_smtp.open_connection(mailserver, 25);
themessage := 'Date: ' ||
TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss') || crlf ||
'From: <'|| mysender ||'>' || crlf ||
'Subject: '|| mysubject|| crlf ||
'To: '||myreceiver || crlf || '' || crlf || mymessage;
utl_smtp.helo(mail_conn, mailserver);
utl_smtp.mail(mail_conn, mysender);
utl_smtp.rcpt(mail_conn, myreceiver);
utl_smtp.data(mail_conn, themessage);
utl_smtp.quit(mail_conn);
EXCEPTION
WHEN OTHERS THEN
NULL;
END kenyadba_send_mail;
/
Execute the procedure with the arguments needed to send mail.
SQLPLUS > exec kenyadba_send_mail('xogutu@gmail.com','tom@kenyadba.com','Oracle Unbreakable linux','Oracle have intoduced ...');
Where
xogutu@gmail.com = sender
tom@kenyadba.com = receiver
Oracle Unbreakable linux = Subject
Oracle have intoduced ... = message.
Monday, July 30, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
An update. You need to:
GRANT EXECUTE ON sys.utl_smtp TO PUBLIC;
CREATE OR REPLACE PUBLIC SYNONYM utl_smtp FOR sys.utl_smtp;
Post a Comment