在postgres中使用sp_send_dbmail替代方法?发送Postgres电子邮件报告的简单方法? [英] sp_send_dbmail alternative in postgres? Easy way to send Postgres email reports?

查看:60
本文介绍了在postgres中使用sp_send_dbmail替代方法?发送Postgres电子邮件报告的简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server在sp_send_dbmail中具有一项很酷的功能(此处的快速指南)可让您通过电子邮件发送报告。 Postgres中是否存在类似的东西?我的postgres托管在Heroku中,因此我可以共享一个数据夹,但是我想知道是否有一种简单的方法来安排电子邮件发送报告。

SQL Server has a cool feature in sp_send_dbmail (quick guide here) that lets you email out reports. Does anything like that exist in Postgres? My postgres is hosted at Heroku so I can share a dataclip, but I am wondering if there's an easy way to schedule emails to send out reports.

推荐答案

您还可以使用 https://github.com/lcalisto/py_pgmail


  1. 通过运行py_pgmail.sql创建py_pgmail函数

  2. 创建函数后,您可以简单地从数据库中的任何位置调用该函数,如下所示:

  1. Create py_pgmail function by running py_pgmail.sql
  2. After the function is created you can simply call the function from anywhere in the database as:

select py_pgmail('sentFromEmail',
                 array['destination emails'],
                 array['cc'],
                 array['bcc'],
                 'Subject',
                 '<USERNAME>','<PASSWORD>',
                 'Text message','HTML message',
                 '<MAIL.MYSERVER.COM:PORT>')


array ['cc'] array ['bcc'] 可以是空数组,例如 array ['']

array['cc'] and array['bcc'] can be empty arrays like array['']

这篇关于在postgres中使用sp_send_dbmail替代方法?发送Postgres电子邮件报告的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆