2026-03-12 20:23:15
This commit is contained in:
28
vg/utl_smtp.sql
Normal file
28
vg/utl_smtp.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
DECLARE
|
||||
c Utl_Smtp.connection;
|
||||
|
||||
PROCEDURE send_header(NAME IN VARCHAR2, HEADER IN VARCHAR2) AS
|
||||
BEGIN
|
||||
Utl_Smtp.write_data(c, NAME || ': ' || HEADER || Utl_Tcp.CRLF);
|
||||
END;
|
||||
|
||||
BEGIN
|
||||
c := Utl_Smtp.open_connection('192.168.1.10');
|
||||
Utl_Smtp.helo(c, 'vishalgupta.co.uk');
|
||||
Utl_Smtp.mail(c, 'vishal@vishalgupta.co.uk');
|
||||
Utl_Smtp.rcpt(c, 'vishal@vishalgupta.co.uk');
|
||||
Utl_Smtp.open_data(c);
|
||||
send_header('From', '"Sender" <vishal@vishalgupta.co.uk>');
|
||||
send_header('To', '"Recipient" <vishal@vishalgupta.co.uk>');
|
||||
send_header('Subject', 'Hello');
|
||||
Utl_Smtp.write_data(c, Utl_Tcp.CRLF || 'Hello, world!');
|
||||
Utl_Smtp.close_data(c);
|
||||
Utl_Smtp.quit(c);
|
||||
EXCEPTION
|
||||
WHEN Utl_Smtp.transient_error OR Utl_Smtp.permanent_error THEN
|
||||
Utl_Smtp.quit(c);
|
||||
RAISE_APPLICATION_ERROR(-20000,
|
||||
'Failed to send mail due to the following error: ' || SQLERRM);
|
||||
END;
|
||||
/
|
||||
|
||||
Reference in New Issue
Block a user