Sample code to send e-mail:
DECLARE
c utl_smtp.connection;
PROCEDURE send_header(name VARCHAR2, header VARCHAR2) AS
BEGIN
utl_smtp.write_data(c,name ||':'|| header || UTL_TCP.CRLF);
END;
BEGIN
c := utl_smtp.open_connection('mail.denilson.com.br');
utl_smtp.helo(c, 'Teste');
utl_smtp.mail(c, 'denilson@denilson.com.br');
utl_smtp.rcpt(c, 'denilson@denilson.com.br');
utl_smtp.open_data(c);
send_header('From', 'denilson@denilson.com.br');
send_header('To', 'denilson@denilson.com.br');
send_header('Cc', 'denilson@denilson.com.br');
send_header('Subject', 'Teste');
utl_smtp.write_data(c, UTL_TCP.CRLF || 'Teste!'); -- Body message
utl_smtp.close_data(c);
utl_smtp.quit(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
BEGIN
utl_smtp.quit(c);
EXCEPTION
WHEN utl_smtp.transient_error
OR utl_smtp.permanent_error THEN
NULL;
END;
raise_application_error(-20000, SQLERRM);
END;
/
Comentários
Postar um comentário