跳转到主要内容

pg_smtp_client

使用SMTP从PostgreSQL内发送邮件的客户端扩展

pg_smtp_client · 使用SMTP从PostgreSQL内发送邮件的客户端扩展

概览

ID扩展软件包版本类别许可证编程语言
4180pg_smtp_clientpg_smtp_client0.2.1UTILMITRust
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d--否是否是否否
Upstream GitHub repository is archived.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
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
软件包版本平台仓库大小下载
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
软件包版本平台仓库大小下载
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
软件包版本平台仓库大小下载
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
软件包版本平台仓库大小下载
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
软件包版本平台仓库大小下载
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

源码

pig build pkg pg_smtp_client;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

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

使用 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 EXTENSION pg_smtp_client;

用法

启用扩展

连接到 PostgreSQL 并执行以下命令。

CREATE EXTENSION IF NOT EXISTS pg_smtp_client CASCADE;

使用 smtp_client.send_email() 函数发送电子邮件。

函数参数

参数类型说明系统配置(可选)
subjecttext邮件主题
bodytext邮件正文
htmlboolean正文是否为 HTML 格式(true)或纯文本格式(false)
from_addresstext发件人邮箱地址smtp_client.from_address
recipientstext[]收件人邮箱地址列表
ccstext[]抄送邮箱地址列表
bccstext[]密送邮箱地址列表
smtp_servertext使用的 SMTP 服务器地址smtp_client.server
smtp_portintegerSMTP 服务器端口smtp_client.port
smtp_tlsboolean是否使用 TLS 加密smtp_client.tls
smtp_usernametextSMTP 服务器登录用户名smtp_client.username
smtp_passwordtextSMTP 服务器登录密码smtp_client.password

默认配置

您可以为上表中标注的部分参数配置系统级默认值,方法如下:

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();

使用示例

发送邮件:

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');

使用已配置的默认值发送邮件:

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

或者使用命名参数:

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

表格阅读器