Skip to content

pg_smtp_client

PostgreSQL extension to send email using SMTP

pg_smtp_client · PostgreSQL extension to send email using SMTP

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4180pg_smtp_clientpg_smtp_client0.2.1UTILMITRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono
Upstream GitHub repository is archived.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.2.119 18 17 16 15pg_smtp_client-
RPMPIGSTY0.2.119 18 17 16 15pg_smtp_client_$v-
DEBPIGSTY0.2.119 18 17 16 15postgresql-$v-pg-smtp-client-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el8.aarch64N/APIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el9.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el9.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el10.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el10.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d12.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d12.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d13.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d13.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u22.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u22.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u24.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u24.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u26.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u26.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
PackageVersionOSORGSIZEFile URL
pg_smtp_client_190.2.1el9.x86_64pigsty1.3 MiBpg_smtp_client_19-0.2.1-4PGSTY.el9.x86_64.rpm
pg_smtp_client_190.2.1el9.aarch64pigsty1.3 MiBpg_smtp_client_19-0.2.1-4PGSTY.el9.aarch64.rpm
pg_smtp_client_190.2.1el10.x86_64pigsty1.3 MiBpg_smtp_client_19-0.2.1-4PGSTY.el10.x86_64.rpm
pg_smtp_client_190.2.1el10.aarch64pigsty1.3 MiBpg_smtp_client_19-0.2.1-4PGSTY.el10.aarch64.rpm
postgresql-19-pg-smtp-client0.2.1d12.x86_64pigsty931.2 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~bookworm_amd64.deb
postgresql-19-pg-smtp-client0.2.1d12.aarch64pigsty817.4 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~bookworm_arm64.deb
postgresql-19-pg-smtp-client0.2.1d13.x86_64pigsty931.3 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~trixie_amd64.deb
postgresql-19-pg-smtp-client0.2.1d13.aarch64pigsty818.1 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~trixie_arm64.deb
postgresql-19-pg-smtp-client0.2.1u22.x86_64pigsty1.0 MiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~jammy_amd64.deb
postgresql-19-pg-smtp-client0.2.1u22.aarch64pigsty968.6 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~jammy_arm64.deb
postgresql-19-pg-smtp-client0.2.1u24.x86_64pigsty1.0 MiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~noble_amd64.deb
postgresql-19-pg-smtp-client0.2.1u24.aarch64pigsty957.2 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~noble_arm64.deb
postgresql-19-pg-smtp-client0.2.1u26.x86_64pigsty1019.2 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~resolute_amd64.deb
postgresql-19-pg-smtp-client0.2.1u26.aarch64pigsty954.4 KiBpostgresql-19-pg-smtp-client_0.2.1-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_180.2.1el8.x86_64pigsty1.2 MiBpg_smtp_client_18-0.2.1-3PIGSTY.el8.x86_64.rpm
pg_smtp_client_180.2.1el8.aarch64pigsty1.1 MiBpg_smtp_client_18-0.2.1-3PIGSTY.el8.aarch64.rpm
pg_smtp_client_180.2.1el9.x86_64pigsty1.3 MiBpg_smtp_client_18-0.2.1-4PGSTY.el9.x86_64.rpm
pg_smtp_client_180.2.1el9.aarch64pigsty1.3 MiBpg_smtp_client_18-0.2.1-4PGSTY.el9.aarch64.rpm
pg_smtp_client_180.2.1el10.x86_64pigsty1.3 MiBpg_smtp_client_18-0.2.1-4PGSTY.el10.x86_64.rpm
pg_smtp_client_180.2.1el10.aarch64pigsty1.3 MiBpg_smtp_client_18-0.2.1-4PGSTY.el10.aarch64.rpm
postgresql-18-pg-smtp-client0.2.1d12.x86_64pigsty928.6 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~bookworm_amd64.deb
postgresql-18-pg-smtp-client0.2.1d12.aarch64pigsty816.0 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~bookworm_arm64.deb
postgresql-18-pg-smtp-client0.2.1d13.x86_64pigsty929.3 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~trixie_amd64.deb
postgresql-18-pg-smtp-client0.2.1d13.aarch64pigsty816.7 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~trixie_arm64.deb
postgresql-18-pg-smtp-client0.2.1u22.x86_64pigsty1.0 MiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~jammy_amd64.deb
postgresql-18-pg-smtp-client0.2.1u22.aarch64pigsty966.2 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~jammy_arm64.deb
postgresql-18-pg-smtp-client0.2.1u24.x86_64pigsty1023.8 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~noble_amd64.deb
postgresql-18-pg-smtp-client0.2.1u24.aarch64pigsty954.2 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~noble_arm64.deb
postgresql-18-pg-smtp-client0.2.1u26.x86_64pigsty1015.8 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~resolute_amd64.deb
postgresql-18-pg-smtp-client0.2.1u26.aarch64pigsty951.9 KiBpostgresql-18-pg-smtp-client_0.2.1-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_170.2.1el8.x86_64pigsty1.2 MiBpg_smtp_client_17-0.2.1-3PIGSTY.el8.x86_64.rpm
pg_smtp_client_170.2.1el8.aarch64pigsty1.1 MiBpg_smtp_client_17-0.2.1-3PIGSTY.el8.aarch64.rpm
pg_smtp_client_170.2.1el9.x86_64pigsty1.3 MiBpg_smtp_client_17-0.2.1-4PGSTY.el9.x86_64.rpm
pg_smtp_client_170.2.1el9.aarch64pigsty1.3 MiBpg_smtp_client_17-0.2.1-4PGSTY.el9.aarch64.rpm
pg_smtp_client_170.2.1el10.x86_64pigsty1.3 MiBpg_smtp_client_17-0.2.1-4PGSTY.el10.x86_64.rpm
pg_smtp_client_170.2.1el10.aarch64pigsty1.3 MiBpg_smtp_client_17-0.2.1-4PGSTY.el10.aarch64.rpm
postgresql-17-pg-smtp-client0.2.1d12.x86_64pigsty926.9 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~bookworm_amd64.deb
postgresql-17-pg-smtp-client0.2.1d12.aarch64pigsty813.7 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~bookworm_arm64.deb
postgresql-17-pg-smtp-client0.2.1d13.x86_64pigsty926.8 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~trixie_amd64.deb
postgresql-17-pg-smtp-client0.2.1d13.aarch64pigsty814.8 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~trixie_arm64.deb
postgresql-17-pg-smtp-client0.2.1u22.x86_64pigsty1.0 MiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~jammy_amd64.deb
postgresql-17-pg-smtp-client0.2.1u22.aarch64pigsty962.1 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~jammy_arm64.deb
postgresql-17-pg-smtp-client0.2.1u24.x86_64pigsty1021.9 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~noble_amd64.deb
postgresql-17-pg-smtp-client0.2.1u24.aarch64pigsty951.6 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~noble_arm64.deb
postgresql-17-pg-smtp-client0.2.1u26.x86_64pigsty1013.2 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~resolute_amd64.deb
postgresql-17-pg-smtp-client0.2.1u26.aarch64pigsty949.8 KiBpostgresql-17-pg-smtp-client_0.2.1-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_160.2.1el8.x86_64pigsty1.2 MiBpg_smtp_client_16-0.2.1-3PIGSTY.el8.x86_64.rpm
pg_smtp_client_160.2.1el8.aarch64pigsty1.1 MiBpg_smtp_client_16-0.2.1-3PIGSTY.el8.aarch64.rpm
pg_smtp_client_160.2.1el9.x86_64pigsty1.3 MiBpg_smtp_client_16-0.2.1-4PGSTY.el9.x86_64.rpm
pg_smtp_client_160.2.1el9.aarch64pigsty1.3 MiBpg_smtp_client_16-0.2.1-4PGSTY.el9.aarch64.rpm
pg_smtp_client_160.2.1el10.x86_64pigsty1.3 MiBpg_smtp_client_16-0.2.1-4PGSTY.el10.x86_64.rpm
pg_smtp_client_160.2.1el10.aarch64pigsty1.3 MiBpg_smtp_client_16-0.2.1-4PGSTY.el10.aarch64.rpm
postgresql-16-pg-smtp-client0.2.1d12.x86_64pigsty925.9 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~bookworm_amd64.deb
postgresql-16-pg-smtp-client0.2.1d12.aarch64pigsty812.8 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~bookworm_arm64.deb
postgresql-16-pg-smtp-client0.2.1d13.x86_64pigsty925.1 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~trixie_amd64.deb
postgresql-16-pg-smtp-client0.2.1d13.aarch64pigsty813.7 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~trixie_arm64.deb
postgresql-16-pg-smtp-client0.2.1u22.x86_64pigsty1.0 MiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~jammy_amd64.deb
postgresql-16-pg-smtp-client0.2.1u22.aarch64pigsty961.6 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~jammy_arm64.deb
postgresql-16-pg-smtp-client0.2.1u24.x86_64pigsty1019.6 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~noble_amd64.deb
postgresql-16-pg-smtp-client0.2.1u24.aarch64pigsty950.9 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~noble_arm64.deb
postgresql-16-pg-smtp-client0.2.1u26.x86_64pigsty1012.6 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~resolute_amd64.deb
postgresql-16-pg-smtp-client0.2.1u26.aarch64pigsty948.8 KiBpostgresql-16-pg-smtp-client_0.2.1-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_150.2.1el8.x86_64pigsty1.2 MiBpg_smtp_client_15-0.2.1-3PIGSTY.el8.x86_64.rpm
pg_smtp_client_150.2.1el8.aarch64pigsty1.1 MiBpg_smtp_client_15-0.2.1-3PIGSTY.el8.aarch64.rpm
pg_smtp_client_150.2.1el9.x86_64pigsty1.3 MiBpg_smtp_client_15-0.2.1-4PGSTY.el9.x86_64.rpm
pg_smtp_client_150.2.1el9.aarch64pigsty1.3 MiBpg_smtp_client_15-0.2.1-4PGSTY.el9.aarch64.rpm
pg_smtp_client_150.2.1el10.x86_64pigsty1.3 MiBpg_smtp_client_15-0.2.1-4PGSTY.el10.x86_64.rpm
pg_smtp_client_150.2.1el10.aarch64pigsty1.3 MiBpg_smtp_client_15-0.2.1-4PGSTY.el10.aarch64.rpm
postgresql-15-pg-smtp-client0.2.1d12.x86_64pigsty922.4 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~bookworm_amd64.deb
postgresql-15-pg-smtp-client0.2.1d12.aarch64pigsty810.7 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~bookworm_arm64.deb
postgresql-15-pg-smtp-client0.2.1d13.x86_64pigsty922.6 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~trixie_amd64.deb
postgresql-15-pg-smtp-client0.2.1d13.aarch64pigsty811.1 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~trixie_arm64.deb
postgresql-15-pg-smtp-client0.2.1u22.x86_64pigsty1.0 MiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~jammy_amd64.deb
postgresql-15-pg-smtp-client0.2.1u22.aarch64pigsty960.3 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~jammy_arm64.deb
postgresql-15-pg-smtp-client0.2.1u24.x86_64pigsty1016.4 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~noble_amd64.deb
postgresql-15-pg-smtp-client0.2.1u24.aarch64pigsty946.5 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~noble_arm64.deb
postgresql-15-pg-smtp-client0.2.1u26.x86_64pigsty1008.7 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~resolute_amd64.deb
postgresql-15-pg-smtp-client0.2.1u26.aarch64pigsty945.0 KiBpostgresql-15-pg-smtp-client_0.2.1-4PGSTY~resolute_arm64.deb

Source

pig build pkg pg_smtp_client;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_smtp_client;		# install by package name

pig install pg_smtp_client -v 19;   # install for PG 19
pig install pg_smtp_client -v 18;   # install for PG 18
pig install pg_smtp_client -v 17;   # install for PG 17
pig install pg_smtp_client -v 16;   # install for PG 16
pig install pg_smtp_client -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_smtp_client;

Usage

Enabling the extension

Connect to postgres and run the following command.

CREATE EXTENSION IF NOT EXISTS pg_smtp_client CASCADE;

Use the smtp_client.send_email() function to send an email.

Function Parameters

ParameterTypeDescriptionSystem Configuration (Optional)
subjecttextThe subject of the email
bodytextThe body of the email
htmlbooleanWhether the body is HTML (true) or plain text (false)
from_addresstextThe from email addresssmtp_client.from_address
recipientstext[]The email addresses of the recipients
ccstext[]The email addresses to CCs
bccstext[]The email addresses to BCCs
smtp_servertextThe SMTP server to usesmtp_client.server
smtp_portintegerThe port of the SMTP serversmtp_client.port
smtp_tlsbooleanWhether to use TLSsmtp_client.tls
smtp_usernametextThe username for the SMTP serversmtp_client.username
smtp_passwordtextThe password for the SMTP serversmtp_client.password

Default Configuration

You can configure the following system-wide default values for some of the parameters (as indiciated in the table above) like this:

ALTER SYSTEM SET smtp_client.server TO 'smtp.example.com';
ALTER SYSTEM SET smtp_client.port TO 587;
ALTER SYSTEM SET smtp_client.tls TO true;
ALTER SYSTEM SET smtp_client.username TO 'MySmtpUsername';
ALTER SYSTEM SET smtp_client.password TO 'MySmtpPassword';
ALTER SYSTEM SET smtp_client.from_address TO 'from@example.com';
SELECT pg_reload_conf();

Usage Examples

Send an email:

SELECT smtp_client.send_email('test subject', 'test body', false, 'from@example.com', array['to@example.com'], null, null, 'smtp.example.com', 587, true, 'username', 'password');

Send an email using configured default values:

SELECT smtp_client.send_email('test subject', 'test body', false, null, array['to@example.com']);

Or, using named arguments:

SELECT smtp_client.send_email('test subject', 'test body', recipients => array['to@example.com']);

Table reader