The pg_utl_smtp extension, which brings Oracle-style UTL_SMTP email capabilities directly into PostgreSQL, has shipped version 2.0.0. Maintained as part of the HexaRocket project, the extension lets triggers and stored procedures send email notifications from inside the database, so data-driven actions such as security alerts or threshold notifications no longer need to wait for an application layer to intervene. Its API and behaviour mirror the Oracle UTL_SMTP package, which keeps ports of existing Oracle code close to the original.
The headline addition in this major release is an asynchronous mode, enabled through the setting pg_utl_smtp.asynchronous. Oracle's own implementation has no equivalent feature; according to the announcement, it is primarily useful when porting the MSSQL sp_send_dbmail() procedure to PostgreSQL. Other changes in the release:
- Errors returned by the SMTP server for
HELO/EHLO,MAIL,RCPT,DATA, end ofDATAorQUITnow raise an error instead of being silently tolerated. - A duplicate
EHLOsent at connection time has been fixed. - SSL/TLS connections are now implemented via
secure_connection_before_smtp. QUITreleases the connection, and a secondQUITno longer has an effect.
For developers, the stricter error reporting is arguably as significant as the async mode: failures during the SMTP handshake or message transfer were previously easy to miss, and database-triggered notifications that fail silently are hard to debug. Surfacing those responses as errors makes broken mail paths visible in the usual PostgreSQL error flow. Combined with optional TLS and the new asynchronous path, v2.0 makes the extension more practical for production alerting that originates entirely inside the database.
Source: https://www.postgresql.org/about/news/pg_utl_smtp-v20-released-3395/