Данный пример подразумевает, что ACL(Access Control List) уже настроен.
CREATE OR REPLACE PROCEDURE send_simple_mail
(p_to IN VARCHAR2,
p_from IN VARCHAR2,
p_message IN VARCHAR2,
p_smtp_host IN VARCHAR2,
p_smtp_port IN NUMBER DEFAULT 25)
AS
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
UTL_SMTP.helo(l_mail_conn, p_smtp_host);
/* UTL_SMTP.command(l_mail_conn,'AUTH LOGIN');
UTL_SMTP.command(l_mail_conn,utl_raw.cast_to_varchar2
(utl_encode.base64_encode(utl_raw.cast_to_raw('myuser@mysmtpserver'))));
UTL_SMTP.command(l_mail_conn,utl_raw.cast_to_varchar2
(utl_encode.base64_encode(utl_raw.cast_to_raw('mypassword')))); */
UTL_SMTP.mail(l_mail_conn, p_from);
UTL_SMTP.rcpt(l_mail_conn, p_to);
UTL_SMTP.data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.quit(l_mail_conn);
END;
BEGIN
send_simple_mail (p_to => 'receiver@receivermail.net',
p_from => 'myuser@mysmtpserver',
p_message => 'Отправка электронной почты ( UTL_SMTP, Oracle 11g)',
p_smtp_host => 'mysmtpserver');
END;