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 -- Open connection to SMTP gateway c := UTL_SMTP.OPEN_CONNECTION('smtp.server.acme.com'); UTL_SMTP.HELO(c, 'acme.com'); UTL_SMTP.MAIL(c, 'userA@acme.com'); UTL_SMTP.RCPT(c, 'userB@acme.com'); UTL_SMTP.OPEN_DATA(c); send_header('From', '"Oracle Admin"Feel free to modify this code sample for your needs. More information can be found in the Oracle documentation for the UTL_SMTP supplied PL/SQL package.
'); send_header('To', '"Bob Smith" '); send_header('Subject', 'Automated Database Email'); UTL_SMTP.WRITE_DATA(c, utl_tcp.CRLF || 'This is an automated email from the Oracle database.'); UTL_SMTP.WRITE_DATA(c, utl_tcp.CRLF || 'The database is working for you!'); UTL_SMTP.CLOSE_DATA(c); UTL_SMTP.QUIT(c); END; /
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.