pg_utl_smtp

pg_utl_smtp

pg_utl_smtp : Oracle UTL_SMTP compatibility extension for PostgreSQL

Overview

ID Extension Package Version Category License Language
9290
pg_utl_smtp
pg_utl_smtp
1.0.0
SIM
PostgreSQL
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Schemas utl_smtp
Requires
plperlu

runtime requires plperlu and Perl Net::SMTP

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PGDG
1.0.0
18
17
16
15
14
pg_utl_smtp plperlu
RPM
PGDG
1.0
18
17
16
15
14
pg_utl_smtp_$v -
DEB
PIGSTY
1.0.0
18
17
16
15
14
postgresql-$v-utl-smtp -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
el8.aarch64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
el9.x86_64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
el9.aarch64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
el10.x86_64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
el10.aarch64
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
PGDG 1.0
d12.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d12.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d13.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d13.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
Package Version OS ORG SIZE File URL
pg_utl_smtp_18 1.0 el8.x86_64 pgdg 12.5 KiB pg_utl_smtp_18-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_18 1.0 el8.aarch64 pgdg 12.4 KiB pg_utl_smtp_18-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_18 1.0 el9.x86_64 pgdg 12.4 KiB pg_utl_smtp_18-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_18 1.0 el9.aarch64 pgdg 12.4 KiB pg_utl_smtp_18-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_18 1.0 el10.x86_64 pgdg 12.6 KiB pg_utl_smtp_18-1.0-2PGDG.rhel10.1.noarch.rpm
pg_utl_smtp_18 1.0 el10.aarch64 pgdg 12.5 KiB pg_utl_smtp_18-1.0-2PGDG.rhel10.1.noarch.rpm
postgresql-18-utl-smtp 1.0.0 d12.x86_64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~bookworm_amd64.deb
postgresql-18-utl-smtp 1.0.0 d12.aarch64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~bookworm_arm64.deb
postgresql-18-utl-smtp 1.0.0 d13.x86_64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~trixie_amd64.deb
postgresql-18-utl-smtp 1.0.0 d13.aarch64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~trixie_arm64.deb
postgresql-18-utl-smtp 1.0.0 u22.x86_64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~jammy_amd64.deb
postgresql-18-utl-smtp 1.0.0 u22.aarch64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~jammy_arm64.deb
postgresql-18-utl-smtp 1.0.0 u24.x86_64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~noble_amd64.deb
postgresql-18-utl-smtp 1.0.0 u24.aarch64 pigsty 7.0 KiB postgresql-18-utl-smtp_1.0.0-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_utl_smtp_17 1.0 el8.x86_64 pgdg 12.5 KiB pg_utl_smtp_17-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_17 1.0 el8.aarch64 pgdg 12.4 KiB pg_utl_smtp_17-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_17 1.0 el9.x86_64 pgdg 12.4 KiB pg_utl_smtp_17-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_17 1.0 el9.aarch64 pgdg 12.4 KiB pg_utl_smtp_17-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_17 1.0 el10.x86_64 pgdg 12.6 KiB pg_utl_smtp_17-1.0-2PGDG.rhel10.1.noarch.rpm
pg_utl_smtp_17 1.0 el10.aarch64 pgdg 12.5 KiB pg_utl_smtp_17-1.0-2PGDG.rhel10.1.noarch.rpm
postgresql-17-utl-smtp 1.0.0 d12.x86_64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~bookworm_amd64.deb
postgresql-17-utl-smtp 1.0.0 d12.aarch64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~bookworm_arm64.deb
postgresql-17-utl-smtp 1.0.0 d13.x86_64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~trixie_amd64.deb
postgresql-17-utl-smtp 1.0.0 d13.aarch64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~trixie_arm64.deb
postgresql-17-utl-smtp 1.0.0 u22.x86_64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~jammy_amd64.deb
postgresql-17-utl-smtp 1.0.0 u22.aarch64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~jammy_arm64.deb
postgresql-17-utl-smtp 1.0.0 u24.x86_64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~noble_amd64.deb
postgresql-17-utl-smtp 1.0.0 u24.aarch64 pigsty 7.0 KiB postgresql-17-utl-smtp_1.0.0-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_utl_smtp_16 1.0 el8.x86_64 pgdg 12.5 KiB pg_utl_smtp_16-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_16 1.0 el8.aarch64 pgdg 12.4 KiB pg_utl_smtp_16-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_16 1.0 el9.x86_64 pgdg 12.4 KiB pg_utl_smtp_16-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_16 1.0 el9.aarch64 pgdg 12.4 KiB pg_utl_smtp_16-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_16 1.0 el10.x86_64 pgdg 12.6 KiB pg_utl_smtp_16-1.0-2PGDG.rhel10.1.noarch.rpm
pg_utl_smtp_16 1.0 el10.aarch64 pgdg 12.5 KiB pg_utl_smtp_16-1.0-2PGDG.rhel10.1.noarch.rpm
postgresql-16-utl-smtp 1.0.0 d12.x86_64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~bookworm_amd64.deb
postgresql-16-utl-smtp 1.0.0 d12.aarch64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~bookworm_arm64.deb
postgresql-16-utl-smtp 1.0.0 d13.x86_64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~trixie_amd64.deb
postgresql-16-utl-smtp 1.0.0 d13.aarch64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~trixie_arm64.deb
postgresql-16-utl-smtp 1.0.0 u22.x86_64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~jammy_amd64.deb
postgresql-16-utl-smtp 1.0.0 u22.aarch64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~jammy_arm64.deb
postgresql-16-utl-smtp 1.0.0 u24.x86_64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~noble_amd64.deb
postgresql-16-utl-smtp 1.0.0 u24.aarch64 pigsty 7.0 KiB postgresql-16-utl-smtp_1.0.0-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_utl_smtp_15 1.0 el8.x86_64 pgdg 12.5 KiB pg_utl_smtp_15-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_15 1.0 el8.aarch64 pgdg 12.4 KiB pg_utl_smtp_15-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_15 1.0 el9.x86_64 pgdg 12.4 KiB pg_utl_smtp_15-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_15 1.0 el9.aarch64 pgdg 12.4 KiB pg_utl_smtp_15-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_15 1.0 el10.x86_64 pgdg 12.6 KiB pg_utl_smtp_15-1.0-2PGDG.rhel10.1.noarch.rpm
pg_utl_smtp_15 1.0 el10.aarch64 pgdg 12.5 KiB pg_utl_smtp_15-1.0-2PGDG.rhel10.1.noarch.rpm
postgresql-15-utl-smtp 1.0.0 d12.x86_64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~bookworm_amd64.deb
postgresql-15-utl-smtp 1.0.0 d12.aarch64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~bookworm_arm64.deb
postgresql-15-utl-smtp 1.0.0 d13.x86_64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~trixie_amd64.deb
postgresql-15-utl-smtp 1.0.0 d13.aarch64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~trixie_arm64.deb
postgresql-15-utl-smtp 1.0.0 u22.x86_64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~jammy_amd64.deb
postgresql-15-utl-smtp 1.0.0 u22.aarch64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~jammy_arm64.deb
postgresql-15-utl-smtp 1.0.0 u24.x86_64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~noble_amd64.deb
postgresql-15-utl-smtp 1.0.0 u24.aarch64 pigsty 7.0 KiB postgresql-15-utl-smtp_1.0.0-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_utl_smtp_14 1.0 el8.x86_64 pgdg 12.4 KiB pg_utl_smtp_14-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_14 1.0 el8.aarch64 pgdg 12.4 KiB pg_utl_smtp_14-1.0-2PGDG.rhel8.10.noarch.rpm
pg_utl_smtp_14 1.0 el9.x86_64 pgdg 12.4 KiB pg_utl_smtp_14-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_14 1.0 el9.aarch64 pgdg 12.4 KiB pg_utl_smtp_14-1.0-2PGDG.rhel9.7.noarch.rpm
pg_utl_smtp_14 1.0 el10.x86_64 pgdg 12.6 KiB pg_utl_smtp_14-1.0-2PGDG.rhel10.1.noarch.rpm
pg_utl_smtp_14 1.0 el10.aarch64 pgdg 12.5 KiB pg_utl_smtp_14-1.0-2PGDG.rhel10.1.noarch.rpm
postgresql-14-utl-smtp 1.0.0 d12.x86_64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~bookworm_amd64.deb
postgresql-14-utl-smtp 1.0.0 d12.aarch64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~bookworm_arm64.deb
postgresql-14-utl-smtp 1.0.0 d13.x86_64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~trixie_amd64.deb
postgresql-14-utl-smtp 1.0.0 d13.aarch64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~trixie_arm64.deb
postgresql-14-utl-smtp 1.0.0 u22.x86_64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~jammy_amd64.deb
postgresql-14-utl-smtp 1.0.0 u22.aarch64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~jammy_arm64.deb
postgresql-14-utl-smtp 1.0.0 u24.x86_64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~noble_amd64.deb
postgresql-14-utl-smtp 1.0.0 u24.aarch64 pigsty 7.0 KiB postgresql-14-utl-smtp_1.0.0-2PIGSTY~noble_arm64.deb

Source

pig build pkg pg_utl_smtp;		# build deb

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install pg_utl_smtp;		# install via package name, for the active PG version

pig install pg_utl_smtp -v 18;   # install for PG 18
pig install pg_utl_smtp -v 17;   # install for PG 17
pig install pg_utl_smtp -v 16;   # install for PG 16
pig install pg_utl_smtp -v 15;   # install for PG 15
pig install pg_utl_smtp -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_utl_smtp CASCADE; -- requires plperlu

Usage

pg_utl_smtp: Oracle UTL_SMTP compatibility extension for PostgreSQL

Enabling

CREATE EXTENSION plperlu;
CREATE EXTENSION pg_utl_smtp;

Sending an Email

DO $$
DECLARE
    c utl_smtp.connection;
BEGIN
    c := utl_smtp.open_connection('smtp.example.com', 25);
    CALL utl_smtp.ehlo(c, 'mydomain.com');
    CALL utl_smtp.mail(c, '[email protected]');
    CALL utl_smtp.rcpt(c, '[email protected]');
    CALL utl_smtp.open_data(c);
    CALL utl_smtp.write_data(c, 'From: [email protected]' || E'\r\n');
    CALL utl_smtp.write_data(c, 'To: [email protected]' || E'\r\n');
    CALL utl_smtp.write_data(c, 'Subject: Test Email' || E'\r\n');
    CALL utl_smtp.write_data(c, E'\r\n');
    CALL utl_smtp.write_data(c, 'Hello from PostgreSQL!');
    CALL utl_smtp.close_data(c);
    CALL utl_smtp.quit(c);
END;
$$;

Procedures

  • OPEN_CONNECTION(host, port, tx_timeout, …) - Opens a connection to an SMTP server. Returns a utl_smtp.connection type. Supports SSL/TLS via secure_connection_before_smtp.
  • EHLO(c, domain) / HELO(c, domain) - Performs initial SMTP handshake.
  • MAIL(c, sender) - Initiates a mail transaction.
  • RCPT(c, recipient) - Specifies e-mail recipient. Call multiple times for multiple recipients.
  • OPEN_DATA(c) - Sends the DATA command to begin message body.
  • WRITE_DATA(c, data) - Writes a portion of the message body.
  • WRITE_RAW_DATA(c, data) - Writes raw data to the message body.
  • CLOSE_DATA(c) - Closes the data session.
  • QUIT(c) - Terminates the SMTP session and disconnects.

Connection Type

-- utl_smtp.connection composite type
(host varchar(255), port integer, tx_timeout integer,
 private_tcp_con integer, private_state integer)

Notes

  • Requires the Perl Net::SMTP module installed on the system
  • Use E'\r\n' for line breaks instead of utl_tcp.crlf
  • The wallet_path and wallet_password parameters are not used
Last updated on