Utl_mail Introduction
The utl_mail utility package is a new tool for sending emails in Oracle10g. Easy to use.
Utl_mail installation and configuration
By default, Oracle10g does not install this package. You can run the following script to install sqlplus:
Step 1: run the following two script files through sqlplus
{ORACLE_HOME}/rdbms/admin/utlmail. SQL
{ORACLE_HOME}/rdbms/admin/prvtmail. PLB
Step 2: configure the dynamic initialization parameter smtp_out_server = smtpserver: Port [, smtpserver: Port,...]
Note: This SMTP server must be a normal method-you do not need to authenticate account information for sending emails, not ESMTP! This is a problem that many people encounter.
You can also configure multiple SMTP servers.
Step 3: Configure Mail forwarding on the SMTP server to enable your local area network SMTP server to send Internet mail.
Step 4: Remember to grant the utl_mail package executable permission to common users.
Example: grant execute on utl_mail to public;
Use utl_mail
Utl_mail.send (sender =>: sender,
Recipients =>: recipients,
Cc =>: CC,
BCC =>: BCC,
Subject =>: subject,
Message =>: message,
Mime_type =>: mime_type,
Priority =>: priority );
Note: You can solve Chinese garbled problem by setting mime_type: mime_type = 'text/plain; charset = UTF-8'
Utl_mail.send_attach_raw
And
Utl_mail.send_attach_varchar2 (sender =>: sender,
Recipients =>: recipients,
Cc =>: CC,
BCC =>: BCC,
Subject =>: subject,
Message =>: message,
Mime_type =>: mime_type,
Priority =>: priority,
Attachment =>: attachment,
Att_inline => att_inline,
Att_mime_type =>: att_mime_type,
Att_filename =>: att_filename );
The usage is similar to that of utl_mail.send. Only indicates that the content of the attachment is sent as an attachment.
You can specify an att_filename for the content of this attachment. In fact, you must give a file name. Otherwise, it will be mixed with the body message on the mail client!
Note: sender, recipients, subject, and [Attachment] are mandatory fields!