Aim: To send a mail using utl_mail from SQL.
Procedure:
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus '/as sysdba'
SQL> @utlmail.sql
Package created.
Synonym created.
SQL> @prvtmail.plb
Package created.
Package body created.
Grant succeeded.
Package body created.
No errors.
SQL> GRANT EXECUTE ON UTL_MAIL TO PUBLIC;
Grant succeeded.
Test:
SQL> BEGIN
2 EXECUTE IMMEDIATE 'ALTER SESSION SET smtp_out_server = ''mail.testhost.com''';
3 UTL_MAIL.send(sender => 'vbadam@testhost.com',
4 recipients => 'veda.santosh@gmail.com',
5 subject => 'Test Mail',
6 message => 'Hello World',
7 mime_type => 'text; charset=us-ascii');
8 END;
9 /
PL/SQL procedure successfully completed.
And a test mail is received at veda.santosh@gmail.com
Procedure:
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus '/as sysdba'
SQL> @utlmail.sql
Package created.
Synonym created.
SQL> @prvtmail.plb
Package created.
Package body created.
Grant succeeded.
Package body created.
No errors.
SQL> GRANT EXECUTE ON UTL_MAIL TO PUBLIC;
Grant succeeded.
Test:
SQL> BEGIN
2 EXECUTE IMMEDIATE 'ALTER SESSION SET smtp_out_server = ''mail.testhost.com''';
3 UTL_MAIL.send(sender => 'vbadam@testhost.com',
4 recipients => 'veda.santosh@gmail.com',
5 subject => 'Test Mail',
6 message => 'Hello World',
7 mime_type => 'text; charset=us-ascii');
8 END;
9 /
PL/SQL procedure successfully completed.
And a test mail is received at veda.santosh@gmail.com
No comments:
Post a Comment