Oracle Study Notes: Use the utl_mail package to send emails

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.