100 UTL_SMTP → UTL_SMTP is designed for sending e-mail over Simple Mail Transfer Protocol (SMTP). It does not have … UTL_SMTP, all text data (in other words, those in VARCHAR2 ) will be converted to US7ASCII before it is … multibyte data using 8-bit MIME encoding. UTL_SMTP provides for SMTP communication as specified in … chapter discusses the
Summary of UTL_SMTP Subprograms → Table 100-4 UTL_SMTP Subprograms Subprogram Description connection Record Type This is a PL/SQL
Exceptions, Limitations, and Reply Codes → Exceptions Table 100-1 lists the exceptions that can be raised by the API of the UTL_SMTP package … . The network error is transferred to a reply code of 421- service not available. Table 100-1 UTL_SMTP
Syntax → UTL_SMTP.OPEN_DATA ( c IN OUT NOCOPY connection) RETURN reply; UTL_SMTP.OPEN_DATA ( c IN OUT NOCOPY connection); UTL_SMTP.WRITE_DATA ( c IN OUT NOCOPY connection, data IN OUT NOCOPY); UTL_SMTP.WRITE_RAW_DATA ( c IN OUT NOCOPY connection data IN OUT NOCOPY); UTL_SMTP.CLOSE_DATA ( c IN OUT NOCOPY connection) RETURN reply; UTL_SMTP.CLOSE_DATA ( c IN OUT NOCOPY connection);
Usage Notes → The server attempts to resolve the destination address recipient. If successful, it returns the recipient's full name and fully qualified mailbox path. The connection to the server must have already been established via open_connection() and helo() / ehlo() before making this request. Successful verification returns one or more lines beginning with status code 250 or 251.
Usage Notes → This command has no effect except to elicit a successful reply from the server. It can be issued at any time after the connection to the server has been established with open_connection(). The noop() command can be used to verify that the server is still connected and is listening properly. This command will always reply with a single line beginning with status code 250.
quit Function → This function terminates an SMTP session and disconnects from the server.
reply, replies Record Types → These are PL/SQL record types used to represent an SMTP reply line. Each SMTP reply line consists of a reply code followed by a text message. While a single reply line is expected for most SMTP commands, some SMTP commands expect multiple reply lines. For those situations, a PL/SQL table of reply records is used to represent multiple reply lines.
Related Functions → ehlo() ehlo Function This function performs initial handshaking with SMTP server after connecting, with extended information returned.
Syntax → UTL_SMTP.RCPT ( c IN OUT NOCOPY connection, recipient IN OUT NOCOPY, parameters IN OUT NOCOPY) RETURN reply; UTL_SMTP.RCPT ( c IN OUT NOCOPY connection recipient IN OUT NOCOPY, parameters IN OUT NOCOPY); Table 100-12 rcpt Function Parameters Parameter Description c (IN OUT NOCOPY) The SMTP connection. recipient (IN OUT NOCOPY) The e-mail address of the user to which the message is being sent. parameters
Syntax → UTL_SMTP.DATA ( c IN OUT NOCOPY connection body IN OUT NOCOPY) RETURN reply; UTL_SMTP.DATA ( c IN OUT NOCOPY connection body IN OUT NOCOPY);
Parameters → Table 100-14 open_data(), write_data(), write_raw_data(), close_data() Function Parameters Parameter Description c (IN OUT NOCOPY) The SMTP connection. data (IN OUT NOCOPY) The portion of the text of the message to be sent, including headers, in [RFC822] format.
rset Function → This function aborts the current mail transaction.
Syntax → UTL_SMTP.NOOP ( c IN OUT NOCOPY connection) RETURN VARCHAR2; UTL_SMTP.NOOP ( c IN OUT NOCOPY connection);
Parameter → Table 100-18 quit Function Parameters Parameter Description c (IN OUT NOCOPY) The SMTP connection.
Fields → the UTL_SMTP package waits before giving up in a read or write operation in this connection. In read
Usage Notes → The read-only fields in a connection record are used to return information about the SMTP connection after the connection is successfully made with open_connection(). Changing the values of these fields has no effect on the connection. The fields private_xxx are for implementation use only. You should not modify these fields.
Syntax → TYPE reply IS RECORD ( code PLS_INTEGER, -- 3-digit reply code text VARCHAR2(508) -- text message ); TYPE replies IS TABLE OF reply INDEX BY BINARY_INTEGER; -- multiple reply lines
open_connection Function → This function opens a connection to an SMTP server.
Usage Notes → The expected response from the server is a message beginning with status code 220. The version of open_connection() API that returns utl_smtp.connection record is actually the procedure version of open_connection that checks the reply code returned by an SMTP server when the connection is first established. A timeout on the write operations feature is not supported in the current release of this package.