pg_smtp_client

pg_smtp_client

pg_smtp_client : PostgreSQL extension to send email using SMTP

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4170
pg_smtp_client
pg_smtp_client
0.2.1
UTIL
MIT
Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-dt-
No
Yes
No
Yes
no
yes
Relationships
See Also
http
pg_net
pg_html5_email_address
gzip
bzip
zstd
pg_curl
pgjq

manual updated pgrx by Vonng

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.2.1
18
17
16
15
14
13
pg_smtp_client-
RPM
PIGSTY
0.2.1
18
17
16
15
14
13
pg_smtp_client_$v-
DEB
PIGSTY
0.2.1
18
17
16
15
14
13
postgresql-$v-pg-smtp-client-
Linux / PGPG18PG17PG16PG15PG14PG13
el8.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
el8.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
el9.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
el9.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
el10.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
el10.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
d12.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
d12.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
d13.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
d13.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
u22.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
u22.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
u24.x86_64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
u24.aarch64
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
PIGSTY 0.2.1
MISS
PackageVersionOSORGSIZEFile URL
pg_smtp_client_180.2.1el8.x86_64pigsty533.7 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el8.x86_64.rpm
pg_smtp_client_180.2.1el8.aarch64pigsty408.3 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el8.aarch64.rpm
pg_smtp_client_180.2.1el9.x86_64pigsty553.2 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el9.x86_64.rpm
pg_smtp_client_180.2.1el9.aarch64pigsty434.8 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el9.aarch64.rpm
pg_smtp_client_180.2.1el10.x86_64pigsty554.1 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el10.x86_64.rpm
pg_smtp_client_180.2.1el10.aarch64pigsty434.4 KiBpg_smtp_client_18-0.2.1-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-smtp-client0.2.1d12.x86_64pigsty439.7 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-smtp-client0.2.1d12.aarch64pigsty319.4 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-smtp-client0.2.1d13.x86_64pigsty440.0 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-smtp-client0.2.1d13.aarch64pigsty319.6 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-smtp-client0.2.1u22.x86_64pigsty492.8 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-smtp-client0.2.1u22.aarch64pigsty374.1 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-smtp-client0.2.1u24.x86_64pigsty489.2 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~noble_amd64.deb
postgresql-18-pg-smtp-client0.2.1u24.aarch64pigsty370.1 KiBpostgresql-18-pg-smtp-client_0.2.1-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_170.2.1el8.x86_64pigsty533.6 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el8.x86_64.rpm
pg_smtp_client_170.2.1el8.aarch64pigsty408.2 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el8.aarch64.rpm
pg_smtp_client_170.2.1el9.x86_64pigsty553.7 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el9.x86_64.rpm
pg_smtp_client_170.2.1el9.aarch64pigsty434.7 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el9.aarch64.rpm
pg_smtp_client_170.2.1el10.x86_64pigsty554.3 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el10.x86_64.rpm
pg_smtp_client_170.2.1el10.aarch64pigsty434.4 KiBpg_smtp_client_17-0.2.1-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-smtp-client0.2.1d12.x86_64pigsty439.9 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-smtp-client0.2.1d12.aarch64pigsty319.2 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-smtp-client0.2.1d13.x86_64pigsty440.1 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-smtp-client0.2.1d13.aarch64pigsty319.3 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-smtp-client0.2.1u22.x86_64pigsty492.6 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-smtp-client0.2.1u22.aarch64pigsty374.0 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-smtp-client0.2.1u24.x86_64pigsty489.2 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~noble_amd64.deb
postgresql-17-pg-smtp-client0.2.1u24.aarch64pigsty369.9 KiBpostgresql-17-pg-smtp-client_0.2.1-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_160.2.1el8.x86_64pigsty533.6 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el8.x86_64.rpm
pg_smtp_client_160.2.1el8.aarch64pigsty408.3 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el8.aarch64.rpm
pg_smtp_client_160.2.1el9.x86_64pigsty553.4 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el9.x86_64.rpm
pg_smtp_client_160.2.1el9.aarch64pigsty434.7 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el9.aarch64.rpm
pg_smtp_client_160.2.1el10.x86_64pigsty554.3 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el10.x86_64.rpm
pg_smtp_client_160.2.1el10.aarch64pigsty434.4 KiBpg_smtp_client_16-0.2.1-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-smtp-client0.2.1d12.x86_64pigsty439.9 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-smtp-client0.2.1d12.aarch64pigsty319.3 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-smtp-client0.2.1d13.x86_64pigsty439.9 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-smtp-client0.2.1d13.aarch64pigsty319.3 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-smtp-client0.2.1u22.x86_64pigsty492.5 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-smtp-client0.2.1u22.aarch64pigsty374.0 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-smtp-client0.2.1u24.x86_64pigsty489.2 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~noble_amd64.deb
postgresql-16-pg-smtp-client0.2.1u24.aarch64pigsty370.1 KiBpostgresql-16-pg-smtp-client_0.2.1-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_150.2.1el8.x86_64pigsty533.4 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el8.x86_64.rpm
pg_smtp_client_150.2.1el8.aarch64pigsty408.3 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el8.aarch64.rpm
pg_smtp_client_150.2.1el9.x86_64pigsty552.6 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el9.x86_64.rpm
pg_smtp_client_150.2.1el9.aarch64pigsty434.8 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el9.aarch64.rpm
pg_smtp_client_150.2.1el10.x86_64pigsty553.8 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el10.x86_64.rpm
pg_smtp_client_150.2.1el10.aarch64pigsty434.5 KiBpg_smtp_client_15-0.2.1-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-smtp-client0.2.1d12.x86_64pigsty439.7 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-smtp-client0.2.1d12.aarch64pigsty319.3 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-smtp-client0.2.1d13.x86_64pigsty439.9 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-smtp-client0.2.1d13.aarch64pigsty319.3 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-smtp-client0.2.1u22.x86_64pigsty492.4 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-smtp-client0.2.1u22.aarch64pigsty374.0 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-smtp-client0.2.1u24.x86_64pigsty488.8 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~noble_amd64.deb
postgresql-15-pg-smtp-client0.2.1u24.aarch64pigsty370.1 KiBpostgresql-15-pg-smtp-client_0.2.1-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_smtp_client_140.2.1el8.x86_64pigsty533.4 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el8.x86_64.rpm
pg_smtp_client_140.2.1el8.aarch64pigsty408.3 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el8.aarch64.rpm
pg_smtp_client_140.2.1el9.x86_64pigsty553.0 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el9.x86_64.rpm
pg_smtp_client_140.2.1el9.aarch64pigsty434.7 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el9.aarch64.rpm
pg_smtp_client_140.2.1el10.x86_64pigsty553.5 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el10.x86_64.rpm
pg_smtp_client_140.2.1el10.aarch64pigsty434.4 KiBpg_smtp_client_14-0.2.1-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-smtp-client0.2.1d12.x86_64pigsty439.7 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-smtp-client0.2.1d12.aarch64pigsty319.4 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-smtp-client0.2.1d13.x86_64pigsty440.0 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-smtp-client0.2.1d13.aarch64pigsty319.2 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-smtp-client0.2.1u22.x86_64pigsty492.2 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-smtp-client0.2.1u22.aarch64pigsty374.0 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-smtp-client0.2.1u24.x86_64pigsty488.9 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~noble_amd64.deb
postgresql-14-pg-smtp-client0.2.1u24.aarch64pigsty370.1 KiBpostgresql-14-pg-smtp-client_0.2.1-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_smtp_client;		# build rpm / deb with pig

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

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

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
pig install pg_smtp_client -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_smtp_client;

Usage

Docs: https://github.com/frectonz/pglite-fusion/blob/main/README.md

Enabling the extension

Connect to postgres and run the following command.

CREATE EXTENSION IF NOT EXISTS pg_smtp_client CASCADE;

Usage

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']);
Last updated on