|
|
|
You can send e-mail from a PL/SQL program using the built in UTL_SMTP package. It is written on top of UTL_TCP and implements the SMTP protocol for sending email. You can use it to communicate with an SMTP sever outside the database.
Please note that UTL_SMTP can be used only to send mail though an existing SMTP server. It cannot be used to implement an SMTP server in itself.
The example is for guidance only. Actual code will vary based on your system environment. |
Click here to copy the following block | DECLARE v_FromAddr VARCHAR2(50) := 'oracle@binaryworld.net'; v_ToAddr VARCHAR2(50) := 'your@emailaddress.com'; v_MessageText VARCHAR2(200);
-- Provide the address of the SMTP server instead of 'localhost' v_MailHost VARCHAR2(50):= 'localhost' v_MailConn UTL_SMTP.Connection;
BEGIN -- Here we store the actual message text in the -- variable MessageText -- The fields should be separated by a CR(Carriage Return) -- character which is CHR(10).
v_MessageText:= 'From: '|| v_FromAddr || CHR(10) || 'Subject: Hello from BinaryWorld!' || CHR(10)|| 'Sending message by using UTL_SMTP package.'; v_MainConn := UTL_SMTP.Open_Connection(v_MailHost);
-- Send Mail by using standard SMTP messages:
UTL_SMTP.HELO(v_MailConn, v_MailHost); UTL_SMTP.MAIL(v_MailConn, v_FromAddr); UTL_SMTP.RCPT(v_MailConn, v_ToAddr); UTL_SMTP.DATA(v_MailConn, v_MessageText);
--Close the connection UTL_SMTP.QUIT(v_MailConn, v_MailHost); END; |
|
|
|
Submitted By :
SaiKiran Jetti
(Member Since : 8/21/2004 9:16:25 AM)
|
|
|
Job Description :
I'm computer engineer. I mostly work on Oracle databases - PL/SQL and Developer 9i. I've worked for the IS dept. of a large insurance company and am now working for a software consulting firm.
I am also a freelance writer - I write technical articles about Oracle databases and database fundamentals. |
View all (8) submissions by this author
(Birth Date : 4/7/1980 ) |
|
|