This post would focus on sending mails from Oracle. Of all the nice packages, utl_mail package can be used directly to send emails from Oracle objects. By default, sending mails is disabled from Oracle due to security reasons. To enable, DBA has to run utlmail.sql script and set smtp_out_server parameter in init.ora file.
If utl_mail package is not enabled, you may receive the following error:
Error report: ORA-06550: line 2, column 1: PLS-00201: identifier 'UTL_MAIL.SEND' must be declared ORA-06550: line 2, column 1: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
Now assuming db is configured to send mails, you can use the send procedure to send emails as follows:
begin utl_mail.send ( sender => 'firstname.lastname@example.org', recipients => 'email@example.com', subject => 'Mail from Oracle', message => 'Look, I can send mails from Oracle...', mime_type => 'text; charset=us-ascii' ); end;